. */ /* 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 (!function_exists('a5_textarea')) require_once AFPW_PATH.'includes/A5_field-functions.php'; 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')); add_action('init', array($this, 'afpw_add_rewrite')); add_action('template_redirect', array($this, 'afpw_css_template')); add_action ('wp_enqueue_scripts', array($this, 'afpw_css')); } /* 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'), true); } // 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;

add_query_var('afpwfile'); } function afpw_css_template() { if (get_query_var('afpwfile') == 'css') { header('Content-type: text/css'); echo $this->afpw_write_css(); exit; } } function afpw_css () { $afpw_css_file=get_bloginfo('url').'/?afpwfile=css'; wp_register_style('advanced-fpw', $afpw_css_file, false, '2.9', 'all'); wp_enqueue_style('advanced-fpw'); } // writing css file function afpw_write_css() { $eol = "\r\n"; $css_text='@charset "UTF-8";'.$eol.'/* CSS Document */'.$eol.$eol; $css_text='@charset "UTF-8";'.$eol.'/* CSS Document */'.$eol.$eol; $css_text.='p[id^="afpw_byline"] {'.$eol.'font-size: 0.9em;'.$eol.'}'.$eol; $css_text.='p[id^="afpw_byline"] a {'.$eol.'text-decoration: none !important;'.$eol.'font-weight: normal !important;'.$eol.'}'.$eol; if (!empty(self::$options['link'])) { $afpw_link=str_replace(array("\r\n", "\n", "\r"), ' ', self::$options['link']); $css_text.='div[id^="advanced_featured_post_widget"].widget_advanced_featured_post_widget a {'.$afpw_link.'}'.$eol; } if (!empty(self::$options['hover'])) { $afpw_hover=str_replace(array("\r\n", "\n", "\r"), ' ', self::$options['hover']); $css_text.='div[id^="advanced_featured_post_widget"].widget_advanced_featured_post_widget a:hover {'.$afpw_hover.'}'; } return $css_text; } } $advanced_fpw = new Advanced_FPW; ?>