. */ /* 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_OptionPage')) require_once AFPW_PATH.'class-lib/A5_OptionPageClass.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; $style = '-moz-hyphens: auto;'.$eol.$tab.'-o-hyphens: auto;'.$eol.$tab.'-webkit-hyphens: auto;'.$eol.$tab.'-ms-hyphens: auto;'.$eol.$tab.'hyphens: auto;'; if (!empty(self::$options['afpw_css'])) $style.=$eol.$tab.str_replace('; ', ';'.$eol.$tab, str_replace(array("\r\n", "\n", "\r"), ' ', self::$options['afpw_css'])); A5_DynamicCSS::$styles.='div[id^="advanced_featured_post_widget"].widget_advanced_featured_post_widget {'.$eol.$tab.$style.$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; if (!empty (self::$options['link'])) : $afpw_link=str_replace(array("\r\n", "\n", "\r"), ' ', self::$options['link']); $afpw_link=str_replace('; ', ';'.$eol.$tab, $afpw_link); A5_DynamicCSS::$styles.='div[id^="advanced_featured_post_widget"].widget_advanced_featured_post_widget a {'.$eol.$tab.$afpw_link.$eol.'}'.$eol; endif; if (!empty (self::$options['hover'])) : $afpw_hover=str_replace(array("\r\n", "\n", "\r"), ' ', self::$options['hover']); $afpw_hover=str_replace('; ', ';'.$eol.$tab, $afpw_hover); A5_DynamicCSS::$styles.='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('use_own_css', __('Widget container:', self::language_file), array($this, 'afpw_display_css'), 'afpw_styles', 'afpw_settings', array(__('You can enter your own style for the widgets here. This will overwrite the styles of your theme.', self::language_file), __('If you leave this empty, you can still style every instance of the widget individually.', self::language_file))); 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_display_css($labels) { echo $labels[0].''.$labels[1].''; a5_textarea('afpw_css', 'afpw_options[afpw_css]', @self::$options['afpw_css'], false, array('rows' => 10, 'cols' => 35)); } function afpw_resize_field() { a5_resize_textarea(array('link', 'hover', 'afpw_css')); } // 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), ''.__('Just input something like,', self::language_file).'
'.$eol.'font-weight: bold;
'.$eol.'color: #0000ff;
';
echo 'text-decoration: underline;'.$eol.'
'.__('You most probably have to use "!important" at the end of each line, to make it work.', self::language_file).'
'.$eol; A5_OptionPage::open_form('options.php'); settings_fields('afpw_options'); do_settings_sections('afpw_styles'); submit_button(); A5_OptionPage::close_page(); } function afpw_validate($input) { self::$options = get_option('afpw_options'); self::$options['link']=trim($input['link']); self::$options['hover']=trim($input['hover']); self::$options['afpw_css']=trim($input['afpw_css']); return self::$options; } } $advanced_fpw = new Advanced_FPW; ?>