* @copyright (C) 2011-2014 Luca Grandicelli * @package special-recent-posts-free * @version 2.0.4 * @return boolean true */ function srp_widgets_init() { // Registering SRP widget. register_widget( 'WDG_SpecialRecentPostsFree' ); // Returning true. return true; } /** * srp_check_plugin_compatibility() * * This function does a compatibility test to ensure that all the SRP requirements are met. * * @author Luca Grandicelli * @copyright (C) 2011-2014 Luca Grandicelli * @package special-recent-posts-free * @version 2.0.4 * @return boolean true */ function srp_check_plugin_compatibility() { // Storing all the potential error messages. $errorMessages = array( 'phpversion' => __( "Special Recent Posts FREE Error! You're running an old version of PHP. In order for this plugin to work, you must enable your server with PHP support version 5.0.0+. Please contact your hosting/housing company support, and check how to enable it.", SRP_TRANSLATION_ID), 'gd_info' => __( "Special Recent Posts FREE Error! GD libraries are not supported by your server. Please contact your hosting/housing company support, and check how to enable it. Without these libraries, thumbnails can't be properly resized and displayed.", SRP_TRANSLATION_ID), 'post-thumbnails' => __( "Special Recent Posts FREE Warning! Your theme doesn't support post thumbnail. The plugin will keep on working with first post images only. To enable post thumbnail support, please check the Wordpress documentation", SRP_TRANSLATION_ID), 'cache-exists' => __( "Special Recent Posts FREE Warning! The Cache folder does not exist!. In order to use caching functionality you have to manually create a folder named 'cache' under the special-recent-posts/ directory.", SRP_TRANSLATION_ID), 'cache-writable' => __( "Special Recent Posts FREE Warning! The Cache folder is not writable. In order to use caching functionality you have to set the correct writing permissions on special-recent-posts/cache/ folder. E.G: 0755 or 0775", SRP_TRANSLATION_ID) ); // Checking current PHP version. if ( '-1' == version_compare( phpversion(), SRP_REQUIRED_PHPVER ) ) { // Setting up new Error object. $error_phpversion = new WP_Error( 'broke', $errorMessages['phpversion'] ); // Checking the correct form of the WP Error object. if ( is_wp_error( $error_phpversion ) ) { // Displaying the error message through the WP notice system. printf( '
%s
', $error_phpversion->get_error_message() ); } } // Checking for GD libraries support (required for the PHP Thumbnailer Class to work). if ( !function_exists( 'gd_info' ) ) { // Setting up new Error object. $error_gd_info = new WP_Error( 'broke', $errorMessages['gd_info'] ); // Checking the correct form of the WP Error object. if ( is_wp_error( $error_gd_info ) ) { // Displaying the error message through the WP notice system. printf( '
%s
', $error_gd_info->get_error_message() ); } } // Checking if the active WP theme support featured thumbnails. if ( !current_theme_supports( 'post-thumbnails' ) ) { // Setting up new Error object. $error_post_thumbnails = new WP_Error( 'broke', $errorMessages['post-thumbnails'] ); // Checking the correct form of the WP Error object. if ( is_wp_error( $error_post_thumbnails ) ) { // Displaying the error message through the WP notice system. printf( '
%s
', $error_post_thumbnails->get_error_message() ); } } // Checking if cache folder exixts and it's writable. if ( !file_exists( SRP_PLUGIN_DIR . SRP_CACHE_DIR ) ) { // Setting up new Error object. $error_cache_exists = new WP_Error( 'broke', $errorMessages['cache-exists'] ); // Checking the correct form of the WP Error object. if ( is_wp_error( $error_cache_exists ) ) { // Displaying the error message through the WP notice system. printf( '
%s
', $error_cache_exists->get_error_message() ); } } else if ( !is_writable( SRP_PLUGIN_DIR . SRP_CACHE_DIR) ) { // Setting up new Error object. $error_cache_writable = new WP_Error( 'broke', $errorMessages['cache-writable'] ); // Checking the correct form of the WP Error object. if ( is_wp_error( $error_cache_writable ) ) { // Displaying the error message through the WP notice system. printf( '
%s
', $error_cache_writable->get_error_message() ); } } // Returning true. return true; } /** * srp_admin_menu() * * This function builds the SRP menu items in the administration main WP left menu. * * @author Luca Grandicelli * @copyright (C) 2011-2014 Luca Grandicelli * @package special-recent-posts-free * @version 2.0.4 * @return boolean true */ function srp_admin_menu() { // Creating top level benu entry add_menu_page( 'Special Recent Posts FREE - ' . __( 'General Settings', SRP_TRANSLATION_ID ), 'SRP FREE', 'install_plugins', 'srp-free-settings', 'srp_admin_menu_options', SRP_PLUGIN_URL . SRP_IMAGES_FOLDER . 'wp-menu-icon.png' ); // Creating sub-menu add_submenu_page( 'srp-free-settings', 'Special Recent Posts FREE - ' . __( 'General Settings', SRP_TRANSLATION_ID ), __( 'General Settings', SRP_TRANSLATION_ID ), 'install_plugins', 'srp-free-general-settings', 'srp_admin_menu_options' ); // Returning true. return true; } /** * srp_admin_enqueue_scripts() * * This function registers all the needed stylesheets & JS scripts in order for the SRP plugin to work. * * @author Luca Grandicelli * @copyright (C) 2011-2014 Luca Grandicelli * @package special-recent-posts-free * @version 2.0.4 * @param string $hook The current viewed page hook. * @return boolean true */ function srp_admin_enqueue_scripts( $hook ) { // Switching through the different $hook cases. switch ( $hook ) { // The WP widget page case 'widgets.php': // Enqueuing admin stylesheet. wp_enqueue_style( 'srp-admin-stylesheet', SRP_ADMIN_CSS ); // Enqueuing custom JS init script. wp_enqueue_script( 'srp-custom-js-init' , SRP_JS_INIT, array('jquery'), SRP_PLUGIN_VERSION, true ); break; // The SRP admin settings page. case 'toplevel_page_srp-free-settings': case 'srp-free_page_srp-free-general-settings': // Enqueuing admin stylesheet. wp_enqueue_style( 'srp-admin-stylesheet', SRP_ADMIN_CSS ); // Enqueuing custom JS init script. wp_enqueue_script( 'srp-custom-js-init' , SRP_JS_INIT, array('jquery'), SRP_PLUGIN_VERSION, true ); // Enqueuing the ACE Code highliter plugin JS library. wp_enqueue_script( 'ace-code-highlighter-js', SRP_PLUGIN_URL . SRP_JS_FOLDER . 'plugins/ace/ace.js', '', '1.0.0', true ); // Enqueuing the ACE Code highliter plugin JS mode library. wp_enqueue_script( 'ace-mode-js', SRP_PLUGIN_URL . SRP_JS_FOLDER . 'plugins/ace/mode-css.js', array( 'ace-code-highlighter-js' ), '1.0.0', true ); // Enqueuing the ACE Code highliter custom JS script. wp_enqueue_script( 'ace-custom-css-js', SRP_PLUGIN_URL . SRP_JS_FOLDER . 'plugins/ace/srp-ace-css.js', array( 'jquery', 'ace-code-highlighter-js' ), '1.0.0', true ); break; default: // Returning true. return true; break; } } /** * srp_wp_head() * * This function loads styles & scripts in the WP theme * * @author Luca Grandicelli * @copyright (C) 2011-2014 Luca Grandicelli * @package special-recent-posts-free * @version 2.0.4 * @return boolean true */ function srp_wp_head() { // First of all, let's do a database check. SpecialRecentPostsFree::srp_dboptions_check(); // Importing global default options array. $srp_current_options = get_option( 'srp_plugin_options' ); // Checking if the SRP built-in stylesheet is enabled. if ( 'yes' != $srp_current_options['srp_disable_theme_css'] ) { // Registering front end stylesheet. wp_register_style( 'srp-layout-stylesheet' , SRP_LAYOUT_CSS ); // Enqueuing stylesheet. wp_enqueue_style( 'srp-layout-stylesheet' ); // Checking if there is some custom CSS code available. if ( !empty( $srp_current_options['srp_custom_css'] ) ) { // Outputting custom CSS. echo "'; } } // Returning true. return true; } /** * srp_admin_menu_options() * * This function builds the plugin admin page. * * @author Luca Grandicelli * @copyright (C) 2011-2014 Luca Grandicelli * @package special-recent-posts-free * @version 2.0.4 * @return boolean true */ function srp_admin_menu_options() { // Checking if we have the user has the 'install_plugins' permission enabled. if ( !current_user_can( 'install_plugins' ) ) { // Abort script with message. wp_die( __( 'You do not have sufficient permissions to access this page.', SRP_TRANSLATION_ID ) ); } // Updating and validating data/POST Check. srp_update_data( $_POST ); // Importing global default options array. $srp_current_options = get_option( 'srp_plugin_options' ); ?>

<?php esc_attr_e('The Special Recent Posts PRO logo', SRP_TRANSLATION_ID); ?>

Upgrade Now!

and much more up to %1$s120 customization options available%2$s. Now translated in multiple languages. %3$sDiscover all the new features%4$s', SRP_TRANSLATION_ID ), '', '', '', '' ); ?>

<?php esc_attr_e('The Special Recent Posts FREE logo', SRP_TRANSLATION_ID); ?>

', '', '
' ); ?>

section of your wordpress theme, which means that your rules will take precedence. Just add your CSS here for what you want to change, you don't need to copy all the plugin's stylesheet content.", SRP_TRANSLATION_ID ) . PHP_EOL . '*/'; ?>

http://www.specialrecentposts.com/', esc_url( 'http://www.specialrecentposts.com/?ref=uri_ps' ), __( 'The Special Recent Posts Official Website.', SRP_TRANSLATION_ID ) );?>
http://wordpress.org/support/plugin/special-recent-posts/', esc_url( 'http://wordpress.org/support/plugin/special-recent-posts/' ), __( 'Visit the online Wordpress.org forum to get instant support.', SRP_TRANSLATION_ID ) );?>
http://www.specialrecentposts.com/docs/', esc_url( 'http://www.specialrecentposts.com/docs/?ref=docs_ps' ), __( 'Learn how to use SRP. View the online documentation.', SRP_TRANSLATION_ID ) );?>

', '' ); ?>

* @copyright (C) 2011-2014 Luca Grandicelli * @package special-recent-posts-free * @version 2.0.4 * @global $srp_default_plugin_values The default plugin presets. * @param array $data The $_POST data. * @return boolean true */ function srp_update_data( $data ) { // Checking that $_POST data exists. if ( isset( $_POST['srp_dataform'] ) ) { // Loading global default plugin presets. global $srp_default_plugin_values; // Removing the "srp_dataform" $_POST entry. unset( $data['srp_dataform'] ); // Removing the "submit" $_POST entry. unset( $data['submit'] ); // Validating text fields. foreach ( $data as $k => $v ) { // Assigning global default value to noimage placeholder field, if this is empty. // Checking if the no-image placeholder field is empty. if ( ( empty( $v ) ) && ( 'srp_noimage_url' == $k ) ) { // Assigning the default value to the no-image placeholder. $data[ $k ] = $srp_default_plugin_values[ $k ]; } // If the current processed field is the Custom CSS, strip some slashes from it. if( 'srp_custom_css' == $k ) { // Stripping slashes off the Custom CSS field. $data[ $k ] = stripslashes($v); } } // Updating WP Option with the new $_POST data. update_option( 'srp_plugin_options', $data ); // Displaying the "save settings" message. echo '

' . __( 'Settings Saved', SRP_TRANSLATION_ID ) . '

'; } // Checking for Cache Flush Option. if ( isset( $_POST['srp_cache_flush'] ) && 'yes' == $_POST['srp_cache_flush'] ) { // Setting up cache folder path. $mydir = SRP_PLUGIN_DIR . SRP_CACHE_DIR; // Initializing directory class. $d = dir( $mydir ); // Reading cache folder content. while( $entry = $d->read() ) { // Checking if the cache directory is empty. if ( '.' != $entry && '..' != $entry ) { // Deleting files. unlink( SRP_PLUGIN_DIR . SRP_CACHE_DIR . $entry ); } } // Closing file connection. $d->close(); // Displaying status message. echo '

' . __( 'Cache Folder Cleaned', SRP_TRANSLATION_ID ) . '

'; } // Returning true. return true; }