.
*/
/* Stop direct call */
defined('ABSPATH') OR exit;
if (!defined('RPW_PATH')) define( 'RPW_PATH', plugin_dir_path(__FILE__) );
if (!defined('RPW_BASE')) define( 'RPW_BASE', plugin_basename(__FILE__) );
# loading the framework
if (!class_exists('A5_Image')) require_once RPW_PATH.'class-lib/A5_ImageClass.php';
if (!class_exists('A5_Excerpt')) require_once RPW_PATH.'class-lib/A5_ExcerptClass.php';
if (!class_exists('A5_FormField')) require_once RPW_PATH.'class-lib/A5_FormFieldClass.php';
if (!class_exists('A5_OptionPage')) require_once RPW_PATH.'class-lib/A5_OptionPageClass.php';
if (!class_exists('A5_DynamicFiles')) require_once RPW_PATH.'class-lib/A5_DynamicFileClass.php';
#loading plugin specific classes
if (!class_exists('RPW_Admin')) require_once RPW_PATH.'class-lib/RPW_AdminClass.php';
if (!class_exists('RPW_DynamicCSS')) require_once RPW_PATH.'class-lib/RPW_DynamicCSSClass.php';
if (!class_exists('A5_Recent_Post_Widget')) require_once RPW_PATH.'class-lib/RPW_WidgetClass.php';
class RecentPostWidget {
const language_file = 'a5-recent-posts';
private static $options;
function __construct() {
self::$options = get_option('rpw_options');
if (isset(self::$options['tags'])) $this->update_plugin_options();
register_activation_hook( __FILE__, array(&$this, '_install') );
register_deactivation_hook( __FILE__, array(&$this, '_uninstall') );
add_action('admin_enqueue_scripts', array(&$this, 'enqueue_scripts'));
add_filter('plugin_row_meta', array(&$this, 'register_links'), 10, 2);
add_filter('plugin_action_links', array(&$this, 'register_action_links'), 10, 2);
// import laguage files
load_plugin_textdomain(self::language_file, false , basename(dirname(__FILE__)).'/languages');
$RPW_DynamicCSS = new RPW_DynamicCSS;
$RPW_Admin = new RPW_Admin;
}
/* attach JavaScript file for textarea resizing */
function enqueue_scripts($hook) {
if ($hook != 'widgets.php' && $hook != 'settings_page_a5-recent-posts-settings') return;
wp_register_script('ta-expander-script', plugins_url('ta-expander.js', __FILE__), array('jquery'), '3.0', true);
wp_enqueue_script('ta-expander-script');
}
//Additional links on the plugin page
function register_links($links, $file) {
if ($file == RPW_BASE) {
$links[] = ''.__('FAQ', self::language_file).'';
$links[] = ''.__('Donate', self::language_file).'';
}
return $links;
}
function register_action_links( $links, $file ) {
if ($file == RPW_BASE) array_unshift($links, ''.__('Settings', self::language_file).'');
return $links;
}
// Creating default options on activation
function _install() {
$default = array(
'cache' => array(),
'inline' => false
);
add_option('rpw_options', $default);
}
// Cleaning on deactivation
function _uninstall() {
delete_option('rpw_options');
}
// updating options in case they are outdated
function _update_plugin_options() {
self::$options['cache'] = array();
self::$options['inline'] = false;
unset(self::$options['tags'], self::$options['sizes']);
update_option('rpw_options', self::$options);
}
} // end of class
$A5_Recent_Post_Widget = new RecentPostWidget;
?>