. */ /* Stop direct call */ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) die('Sorry, you don\'t have direct access to this page.'); define( 'AFPW_PATH', plugin_dir_path(__FILE__) ); if (!class_exists('A5_Image')) require_once AFPW_PATH.'class-lib/A5_ImageClass.php'; if (!class_exists('A5_Excerpt')) require_once AFPW_PATH.'class-lib/A5_ExcerptClass.php'; if (!class_exists('Advanced_Featured_Post_Widget')) require_once AFPW_PATH.'class-lib/AFPW_WidgetClass.php'; if (!class_exists('A5_FormField')) require_once AFPW_PATH.'class-lib/A5_FormFieldClass.php'; if (!class_exists('A5_DynamicCSS')) : require_once AFPW_PATH.'class-lib/A5_DynamicCSSClass.php'; $dynamic_css = new A5_DynamicCSS; endif; class Advanced_FPW { const language_file = 'advanced-fpw'; private static $options; function __construct() { self::$options = get_option('afpw_options'); // import laguage files load_plugin_textdomain(self::language_file, false , basename(dirname(__FILE__)).'/languages'); add_action('admin_enqueue_scripts', array($this, 'afpw_js_sheet')); add_filter('plugin_row_meta', array($this, 'afpw_register_links'), 10, 2); add_filter('plugin_action_links', array($this, 'afpw_plugin_action_links'), 10, 2); add_action('admin_init', array($this, 'afpw_init')); register_activation_hook( __FILE__, array($this, 'install_afpw') ); register_deactivation_hook( __FILE__, array($this, 'unset_afpw') ); add_action('admin_menu', array($this, 'afpw_admin_menu')); $eol = "\r\n"; $tab = "\t"; A5_DynamicCSS::$styles .= $eol.'/* CSS portion of the Advanced Featured Post Widget */'.$eol.$eol; A5_DynamicCSS::$styles.='p[id^="afpw_byline"] {'.$eol.$tab.'font-size: 0.9em;'.$eol.'}'.$eol; A5_DynamicCSS::$styles.='p[id^="afpw_byline"] a {'.$eol.$tab.'text-decoration: none !important;'.$eol.$tab.'font-weight: normal !important;'.$eol.'}'.$eol; A5_DynamicCSS::$styles.='div[id^="advanced_featured_post_widget"].widget_advanced_featured_post_widget img {'.$eol.$tab.'height: auto;'.$eol.$tab.'max-width: 100%;'.$eol.'}'.$eol; A5_DynamicCSS::$styles.='div[id^="advanced_featured_post_widget"].widget_advanced_featured_post_widget {'.$eol.$tab.'-moz-hyphens: auto;'.$eol.$tab.'-o-hyphens: auto;'.$eol.$tab.'-webkit-hyphens: auto;'.$eol.$tab.'-ms-hyphens: auto;'.$eol.$tab.'hyphens: auto; '.$eol.'}'.$eol; if (!empty (self::$options['link']) || !empty (self::$options['hover'])) : $afpw_link=str_replace(array("\r\n", "\n", "\r"), ' ', self::$options['link']); $afpw_hover=str_replace(array("\r\n", "\n", "\r"), ' ', self::$options['hover']); $afpw_link=str_replace('; ', ';'.$eol.$tab, $afpw_link); $afpw_hover=str_replace('; ', ';'.$eol.$tab, $afpw_hover); A5_DynamicCSS::$styles.='div[id^="advanced_featured_post_widget"].widget_advanced_featured_post_widget a {'.$eol.$tab.$afpw_link.$eol.'}'.$eol.'div[id^="advanced_featured_post_widget"].widget_advanced_featured_post_widget a:hover {'.$eol.$tab.$afpw_hover.$eol.'}'.$eol; endif; } /* attach JavaScript file for textarea resizing */ function afpw_js_sheet($hook) { if ($hook != 'settings_page_advanced-fpw-settings' && $hook != 'widgets.php') 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 afpw_register_links($links, $file) { $base = plugin_basename(__FILE__); if ($file == $base) : $links[] = ''.__('FAQ', self::language_file).''; $links[] = ''.__('Donate', self::language_file).''; endif; return $links; } function afpw_plugin_action_links( $links, $file ) { $base = plugin_basename(__FILE__); if ($file == $base) array_unshift($links, ''.__('Settings', self::language_file).''); return $links; } // init function afpw_init() { register_setting( 'afpw_options', 'afpw_options', array($this, 'afpw_validate') ); add_settings_section('afpw_settings', __('Styling of the links', self::language_file), array($this, 'afpw_display_section'), 'afpw_styles'); add_settings_field('afpw_link_style', __('Link style:', self::language_file), array($this, 'afpw_link_field'), 'afpw_styles', 'afpw_settings'); add_settings_field('afpw_hover_style', __('Hover style:', self::language_file), array($this, 'afpw_hover_field'), 'afpw_styles', 'afpw_settings'); add_settings_field('afpw_resize', false, array($this, 'afpw_resize_field'), 'afpw_styles', 'afpw_settings'); } function afpw_display_section() { echo '

'.__('Just put some css code here.', self::language_file).'

'; } function afpw_link_field() { a5_textarea('link', 'afpw_options[link]', @self::$options['link'], false, array('cols' => 35, 'rows' => 3)); } function afpw_hover_field() { a5_textarea('hover', 'afpw_options[hover]', @self::$options['hover'], false, array('cols' => 35, 'rows' => 3)); } function afpw_resize_field() { a5_resize_textarea(array('link', 'hover')); } // Creating default options on activation static function install_afpw() { $default = array( 'tags' => array(), 'sizes' => array() ); add_option('afpw_options', $default); } // Cleaning on deactivation static function unset_afpw() { delete_option('afpw_options'); } // Installing options page function afpw_admin_menu() { add_options_page('Advanced FP '.__('Settings', self::language_file), ' Advanced Featured Post Widget', 'administrator', 'advanced-fpw-settings', array($this, 'advanced_fpw_options_page')); } // Calling the options page function advanced_fpw_options_page() { ?>

font-weight: bold;
color: #0000ff;
text-decoration: underline;