<644php /* /* Author: Shoofly Solutions Plugin Name: (Simply) Guest Author Name Slug: guest-author-name Plugin URI: http://plugins.shooflysolutions.com/guest-author-name Description: An ideal plugin for cross posting. Guest Author Name helps you to publish posts by authors without having to add them as users. If the Guest Author field is filled in on the post, the Guest Author name will override the author. The optional Url link allows you to link to another web site. Version: 4.42 Author URI: http://www.shooflysolutions.com Copyright (C) 2015, 2016 Shoofly Solutions Contact me at http://www.shooflysolutions.com Text Domain: sfly_guest_author License: GPL2 License URI: https://www.gnu.org/licenses/gpl-2.0.html */ defined('ABSPATH') or die('No script kiddies please!'); remove_filter('pre_user_description', 'wp_filter_kses'); $path = (plugin_dir_path(__FILE__)); require_once($path . 'guest-author-notices.php'); require_once($path . 'sfly-guest-author-settings.php'); /** * sfly_guest_author class. */ if (!class_exists('sfly_guest_author')): class sfly_guest_author { /** * __construct function. * * @access public * @return void */ private $comment_list; function __construct() { $options = get_option('guest_author_name_settings'); //load settings self::sfly_guest_author_add_filters(); //add filters $this->comment_list = false; //flag to let us know if wp is printing comments add_action('wp_enqueue_scripts', array($this, 'sfly_guest_author_enqueue_scripts')); //enqueue scripts add_action('get_sidebar', array($this, 'sfly_guest_author_add_filters')); // action to disable plugin on the sidebar $disable = isset($options['guest_author_disable_for_comments']) ? true : false; //disable guest authors for comment section if ($disable) { add_filter('wp_list_comments_args', array($this, 'list_comments')); //manage comments } if (is_admin()) //Admin page settings { add_action('add_meta_boxes', array($this, 'add_meta_box')); //meta box settings add_action('save_post', array($this, 'save_meta'), 10, 2); //action when saving post $quickedit = isset($options['guest_author_name_quickedit']) ? true : false; //quick edit enabled? if ($quickedit) //quick edit options { add_action('quick_edit_custom_box', array($this, 'add_quick_meta_box'), 10, 2); add_action('manage_posts_custom_column', array($this, 'render_post_columns'), 10, 2); add_filter('manage_edit-post_columns', array($this, 'change_posttype_columns')); add_action('admin_enqueue_scripts', array($this, 'guest_admin_scripts')); } } } /** * sfly_guest_author_open_link function is not being used currently. * append jQuery to existing script file * @access public * @return void */ function sfly_guest_author_open_link($options, $open = true, $clear = false) { //set the url to open in a new window if ($open || $clear) { $selector = esc_attr($options['guest_author_url_selector_single']); if ($selector) { $script = ''; if ($open) { $script = " (function($) { var url = window.location.href; var href = jQuery('.sfly_guest-author-post $selector' ).attr('href'); if ( url != href ) { $('.sfly_guest-author-post $selector' ).attr('target', '_blank'); } })(jQuery);"; $success = wp_add_inline_script('guest_author_post_scripts', $script); } if ($clear) { $script = " (function($) { $('.sfly_guest-author-post $selector' ).contents().unwrap(); })(jQuery);"; $success = wp_add_inline_script('guest_author_post_scripts', $script); } } } } /** * sfly_guest_author_enqueue_scripts function. * Enqueue Scripts * @access public * @return void */ function sfly_guest_author_enqueue_scripts() { $options = get_option('guest_author_name_settings'); $open = isset($options['guest_author_open_new_window']) ? true : false; $clear = isset($options['guest_author_remove_link']) ? true : false; if ($open || $clear) { wp_enqueue_script('jquery'); wp_enqueue_script('guest_author_post_scripts', plugins_url('assets/guest-author-post.js', __FILE__), array('jquery'), '1.10', true); $this->sfly_guest_author_open_link($options, $open, $clear); } } /** * sfly_guest_author_add_filters function. * Add Faliters * @access public * @return void */ function sfly_guest_author_add_filters() { $admin = isset($options['guest_author_name_admin']) ? true : false; if (!is_admin() || $admin || wp_doing_ajax()) { add_filter('the_author', array($this, 'guest_author_name'), 12); add_filter('get_the_author_display_name', array($this, 'guest_author_name'), 12); } if (!is_admin() || wp_doing_ajax()) { add_action('ampforwp_modify_author_name', array($this, 'guest_author_name'), 12); add_filter('get_the_author_display_name', array($this, 'guest_author_name'), 12); //10-2-2022 add_action('the_post', array($this, 'register_author'), 10); add_filter('author_link', array($this, 'guest_author_link'), 12); add_filter('get_the_author_link', array($this, 'guest_author_link'), 12); add_filter('get_the_author_url', array($this, 'guest_author_link'), 21); add_filter('ampforwp_author_description', array($this, 'guest_author_description_amp'), 12); add_filter('author_description', array($this, 'guest_author_description'), 12); add_filter('get_the_author_description', array($this, 'guest_author_description'), 12); add_filter('get_the_author_id', array($this, 'guest_author_id'), 12); add_filter('author_id', array($this, 'guest_author_id'), 12); add_filter('get_avatar', array($this, 'guest_author_avatar'), 40, 5); add_filter('get_avatar_url', array($this, 'guest_avatar_link'), 40, 3); $include = isset($options['guest_author_include_guest']) ? true : false; add_filter('wpseo_canonical', array($this, 'guest_author_canonical_link')); if ($include) add_action('pre_get_posts', array($this, 'author_query'), 50); //Fix query for author query without guest posts or guest author add_filter("td_wp_booster_module_constructor", array($this, 'set_guest_author_ids'), 10, 2); add_action('comment_form_top', array($this, 'sfly_guest_author_remove_filters'), 10); //remove filters before comments form add_filter('body_class', array($this, 'sfly_guest_author_body_class')); //add some classes to the body class } } /** * sfly_guest_author_remove_filters function. * Remove Filters * @access public * @return void */ function sfly_guest_author_remove_filters() { remove_action('the_post', array($this, 'register_author')); remove_filter('author_link', array($this, 'guest_author_link')); remove_filter('get_the_author_link', array($this, 'guest_author_link')); remove_filter('get_the_author_url', array($this, 'guest_author_link')); remove_filter('author_description', array($this, 'guest_author_description')); remove_filter('get_the_author_description', array($this, 'guest_author_description')); remove_filter('get_the_author_id', array($this, 'guest_author_id')); remove_filter('author_id', array($this, 'guest_author_id')); remove_filter('get_avatar', array($this, 'guest_author_avatar')); remove_filter('get_avatar_url', array($this, 'guest_avatar_link')); remove_filter('wpseo_canonical', array($this, 'guest_author_canonical_link')); remove_action('pre_get_posts', array($this, 'author_query')); //Fix query for author query without guest posts or guest author remove_filter("td_wp_booster_module_constructor", array($this, 'set_guest_author_ids')); remove_filter('the_author', array($this, 'guest_author_name')); remove_filter('get_the_author_display_name', array($this, 'guest_author_name')); remove_filter('body_class', array($this, 'sfly_guest_author_body_class')); //add some classes to the body class } function sfly_guest_author_excerpt($content) { global $authordata; if (isset($authordata) && $authordata->guest_author) { $content = $content . '