Special Recent Posts FREE Edition 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));
if (is_wp_error($error)) {
echo "
" . $error->get_error_message() . "
";
}
}
function srpcheck_gd_error() {
// Setting up new Error.
$error = new WP_Error('broke', __("Special Recent Posts FREE Edition 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));
if (is_wp_error($error)) {
echo "" . $error->get_error_message() . "
";
}
}
function srpcheck_thumbnailsupport_error() {
// Setting up new Error.
$error = new WP_Error('broke', __("Special Recent Posts FREE Edition 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));
if (is_wp_error($error)) {
echo "" . $error->get_error_message() . "
";
}
}
function srpcheck_cache_exists_error() {
// Setting up new Error.
$error = new WP_Error('broke', __("Special Recent Posts FREE Edition Warning! The Cache folder does not exist!. In order to use caching functionality you have to manually create a folder names 'cache' under the special-recent-posts/ folder.", SRP_TRANSLATION_ID));
if (is_wp_error($error)) echo "" . $error->get_error_message() . "
";
}
function srpcheck_cache_writable_error() {
// Setting up new Error.
$error = new WP_Error('broke', __("Special Recent Posts FREE Edition 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));
if (is_wp_error($error)) echo "" . $error->get_error_message() . "
";
}
/*
| ------------------------------------------------------------------
| This is the main function that performs the compatibility check.
| ------------------------------------------------------------------
*/
function check_plugin_compatibility() {
// Checking for PHP version.
$current_ver = phpversion();
// Switching through version compare results.
switch(version_compare($current_ver, SRP_REQUIRED_PHPVER)) {
case -1:
add_action('admin_notices', 'srpcheck_phpver_error');
break;
case 0:
case 1:
break;
}
// Checking for GD support. (required for the PHP Thumbnailer Class to work)
if (!function_exists("gd_info")) {
srpcheck_gd_error();
}
// Checking if the current wordpress theme support featured thumbnails.
if (!current_theme_supports('post-thumbnails')) {
srpcheck_thumbnailsupport_error();
}
// Checking if cache folder exixts and it's writable.
if (!file_exists(SRP_PLUGIN_DIR . SRP_CACHE_DIR)) {
srpcheck_cache_exists_error();
} else if (!is_writable(SRP_PLUGIN_DIR . SRP_CACHE_DIR)) {
srpcheck_cache_writable_error();
}
}
/*
| -----------------------------------------
| This is the main Admin setup function.
| -----------------------------------------
*/
function srp_admin_setup() {
// Adding SubMenu Page.
$srp_settings_page = add_submenu_page('options-general.php', __('Special Recent Posts FREE Edition - Settings Page', 'Special Recent Posts FREE Edition - Settings Page'), __('Special Recent Posts FREE', 'Special Recent Posts FREE'), 'administrator', __FILE__, 'srp_admin_menu_options');
// Using registered $page handle to hook stylesheet loading.
add_action('admin_print_styles-' . $srp_settings_page, 'srp_admin_plugin_add_style');
// Using registered $page handle to hook javascript loading.
add_action('admin_print_scripts-' . $srp_settings_page, 'srp_admin_plugin_add_scripts');
}
/*
| -----------------------------------------
| This function re-register styles
| and scripts in the widget page only.
| -----------------------------------------
*/
function widget_enqueue_scripts($hook) {
if( ('widgets.php' != $hook) ) return;
// Enqueuing plugin admin widget stylesheet.
wp_enqueue_style('srp-admin-stylesheet', SRP_PLUGIN_URL . SRP_ADMIN_CSS);
// Enqueuing Custom Js Init Script.
wp_enqueue_script('srp-custom-js-init' , SRP_PLUGIN_URL . SRP_JS_INIT, array('jquery'), SRP_PLUGIN_VERSION, true);
}
/*
| ----------------------------------------------------
| This is the main function to add admin stylesheet.
| ----------------------------------------------------
*/
function srp_admin_plugin_add_style() {
// Enqueuing plugin admin widget stylesheet.
wp_enqueue_style('srp-admin-stylesheet', SRP_PLUGIN_URL . SRP_ADMIN_CSS);
}
/*
| ----------------------------------------------------
| This is the main function to add admin javascript.
| ----------------------------------------------------
*/
function srp_admin_plugin_add_scripts() {
// Enqueuing Custom Js Init Script.
wp_enqueue_script('srp-custom-js-init' , SRP_PLUGIN_URL . SRP_JS_INIT, array('jquery'), SRP_PLUGIN_VERSION, true);
}
/*
| ----------------------------------------------------
| This is the main function to add widget stylesheet
| into the current theme.
| ----------------------------------------------------
*/
function srp_front_head() {
// Doing a global database options check.
SpecialRecentPostsFree::srp_dboptions_check();
// Importing global default options array.
$srp_current_options = get_option('srp_plugin_options');
// Checking for SRP Stylesheet enabled.
if ($srp_current_options["srp_disable_theme_css"] != "yes") {
// Registering Front End CSS.
wp_register_style('srp-front-stylesheet' , SRP_PLUGIN_URL . SRP_FRONT_CSS);
// Enqueuing Front End CSS.
wp_enqueue_style('srp-front-stylesheet');
// Adding IE7 Fix.
echo "";
}
}
/*
| ---------------------------------------------
| BUILDING PLUGIN OPTION PAGE
| ---------------------------------------------
*/
/*
| --------------------------------------------------------------
| This is the main function that builds the plugin admin page.
| --------------------------------------------------------------
*/
function srp_admin_menu_options() {
// Checking if we have the manage option permission enabled.
if (!current_user_can('manage_options')) {
wp_die(__('You do not have sufficient permissions to access this page.', SRP_TRANSLATION_ID));
}
// For first, let's check if there is some kind of compatibility error.
check_plugin_compatibility();
?>
$v) {
// Assigning global default value to noimage placeholder field, if this is empty.
if ((empty($v)) && ($k == "srp_noimage_url")) $data[$k] = $srp_default_plugin_values[$k];
}
// Updating WP Option with new $_POST data.
update_option('srp_plugin_options', $data);
// Displaying "save settings" message.
echo "" . __('Settings Saved', SRP_TRANSLATION_ID) . "
";
}
// Checking for Cache Flush Option.
if (isset($_POST["cache_flush"]) && $_POST["cache_flush"] == "yes") {
// 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 directory is empty.
if ($entry!= "." && $entry!= "..") {
// Deleting files.
unlink(SRP_PLUGIN_DIR . SRP_CACHE_DIR . $entry);
}
}
// Closing fodler class connection.
$d->close();
// Displaying status message.
echo "" . __('Cache Folder Cleaned', SRP_TRANSLATION_ID) . "
";
}
}