function SicEm() { $this->name = strtolower(get_class($this)); add_filter('syndicated_post', array(&$this, 'process_post'), 10, 2); add_filter('feedwordpress_update_complete', array(&$this, 'process_captured_images'), -1000, 1); add_action('feedwordpress_admin_page_posts_meta_boxes', array(&$this, 'add_settings_box')); add_action('feedwordpress_admin_page_posts_save', array(&$this, 'save_settings'), 10, 2); add_filter('feedwordpress_diagnostics', array(&$this, 'diagnostics'), 10, 2); // If user opts for it, put a gallery at the end of syndicated posts add_filter('the_content', array(&$this, 'the_content'), 200000, 2); global $pagenow; global $sicem_path; if (WP_ADMIN) { // set up image picker through massive fuckery add_action('admin_init', array(&$this, 'fix_async_upload_image')); if (FeedWordPressSettingsUI::is_admin()) { wp_enqueue_style('thickbox'); wp_enqueue_script('sic-em-image-picker', WP_PLUGIN_URL . '/' . $sicem_path . '/image-picker.js', array('thickbox'), false, true); } elseif ('media-upload.php' == $pagenow || 'async-upload.php' == $pagenow) { add_filter('image_send_to_editor', array($this, 'image_send_to_editor'), 1, 8); add_filter('gettext', array($this, 'replace_text_in_thickbox'), 1, 3); add_filter('media_upload_tabs', array($this, 'media_upload_tabs')); } } }
public function admin_init() { global $pagenow; global $sicem_path; if (class_exists('FeedWordPressSettingsUI')) { if (FeedWordPressSettingsUI::is_admin()) { wp_enqueue_style('thickbox'); wp_enqueue_script('sic-em-image-picker', WP_PLUGIN_URL . '/' . $sicem_path . '/image-picker.js', array('thickbox'), false, true); } elseif ('media-upload.php' == $pagenow || 'async-upload.php' == $pagenow) { add_filter('image_send_to_editor', array($this, 'image_send_to_editor'), 1, 8); add_filter('gettext', array($this, 'replace_text_in_thickbox'), 1, 3); add_filter('media_upload_tabs', array($this, 'media_upload_tabs')); } } }
function syndicated_sources_box($page, $box = NULL) { global $fwp_path; $links = FeedWordPress::syndicated_links(array("hide_invisible" => false)); $sources = $this->sources('*'); $visibility = $this->visibility_toggle(); $showInactive = $this->show_inactive(); $hrefPrefix = $this->form_action(); ?> <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> </div> <div class="tablenav"> <div id="add-multiple-uri" class="hide-if-js"> <form action="<?php print $hrefPrefix; ?> &visibility=<?php print $visibility; ?> " method="post"> <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> </div> <h4>Add Multiple Sources</h4> <div>Enter one feed or website URL per line. If a URL links to a website which provides multiple feeds, FeedWordPress will use the first one listed.</div> <div><textarea name="multilookup" rows="8" cols="60" style="vertical-align: top"></textarea></div> <div style="border-top: 1px dotted black; padding-top: 10px"> <div class="alignright"><input type="submit" class="button-primary" name="multiadd" value="<?php print FWP_SYNDICATE_NEW; ?> " /></div> <div class="alignleft"><input type="button" class="button-secondary" name="action" value="<?php print FWP_CANCEL_BUTTON; ?> " id="turn-off-multiple-sources" /></div> </div> </form> </div> <!-- id="add-multiple-uri" --> <div id="upload-opml" style="float: right" class="hide-if-js"> <h4>Import source list</h4> <p>You can import a list of sources in OPML format, either by providing a URL for the OPML document, or by uploading a copy from your computer.</p> <form enctype="multipart/form-data" action="<?php print $hrefPrefix; ?> &visibility=<?php print $visibility; ?> " method="post"> <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /></div> <div style="clear: both"><label for="opml-lookup" style="float: left; width: 8.0em; margin-top: 5px;">From URL:</label> <input type="text" id="opml-lookup" name="opml_lookup" value="OPML document" /></div> <div style="clear: both"><label for="opml-upload" style="float: left; width: 8.0em; margin-top: 5px;">From file:</label> <input type="file" id="opml-upload" name="opml_upload" /></div> <div style="border-top: 1px dotted black; padding-top: 10px"> <div class="alignright"><input type="submit" class="button-primary" name="action" value="<?php print FWP_SYNDICATE_NEW; ?> " /></div> <div class="alignleft"><input type="button" class="button-secondary" name="action" value="<?php print FWP_CANCEL_BUTTON; ?> " id="turn-off-opml-upload" /></div> </div> </form> </div> <!-- id="upload-opml" --> <div id="add-single-uri" class="alignright"> <form id="syndicated-links" action="<?php print $hrefPrefix; ?> &visibility=<?php print $visibility; ?> " method="post"> <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> </div> <ul class="subsubsub"> <li><label for="add-uri">New source:</label> <input type="text" name="lookup" id="add-uri" value="Website or feed URI" /> <?php FeedWordPressSettingsUI::magic_input_tip_js('add-uri'); FeedWordPressSettingsUI::magic_input_tip_js('opml-lookup'); ?> <input type="hidden" name="action" value="feedfinder" /> <input type="submit" class="button-secondary" name="action" value="<?php print FWP_SYNDICATE_NEW; ?> " /> <div style="text-align: right; margin-right: 2.0em"><a id="turn-on-multiple-sources" href="#add-multiple-uri"><img style="vertical-align: middle" src="<?php print plugins_url('/' . $fwp_path . '/down.png'); ?> " alt="" /> add multiple</a> <span class="screen-reader-text"> or </span> <a id="turn-on-opml-upload" href="#upload-opml"><img src="<?php print plugins_url('/' . $fwp_path . '/plus.png'); ?> " alt="" style="vertical-align: middle" /> import source list</a></div> </li> </ul> </form> </div> <!-- class="alignright" --> <div class="alignleft"> <?php if (count($sources[$visibility]) > 0) { $this->manage_page_links_subsubsub($sources, $showInactive); } ?> </div> <!-- class="alignleft" --> </div> <!-- class="tablenav" --> <form id="syndicated-links" action="<?php print $hrefPrefix; ?> &visibility=<?php print $visibility; ?> " method="post"> <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> </div> <?php if ($showInactive) { ?> <div style="clear: right" class="alignright"> <p style="font-size: smaller; font-style: italic">FeedWordPress used to syndicate posts from these sources, but you have unsubscribed from them.</p> </div> <?php } ?> <?php if (count($sources[$visibility]) > 0) { $this->display_button_bar($showInactive); } else { $this->manage_page_links_subsubsub($sources, $showInactive); } fwp_syndication_manage_page_links_table_rows($sources[$visibility], $this, $visibility); $this->display_button_bar($showInactive); ?> </form> <?php }
function display_alt_feed_box($lookup, $params = false) { global $fwp_post; if (is_bool($params)) { $params = array("alt" => $params); } $params = wp_parse_args($params, array("alt" => false, "err" => NULL, "auth" => NULL, "password" => NULL, "username" => NULL)); $alt = $params['alt']; ?> <form action="admin.php?page=<?php print $GLOBALS['fwp_path']; ?> /<?php echo basename(__FILE__); ?> " method="post"> <div class="inside"><?php FeedWordPressCompatibility::stamp_nonce($this->dispatch); ?> <fieldset class="alt" <?php if (!$alt) { ?> style="margin: 1.0em 3.0em; font-size: smaller;"<?php } ?> > <legend><?php if ($alt) { ?> Alternative feeds<?php } else { ?> Find feeds<?php } ?> </legend> <?php if ($alt) { ?> <h3>Use a different feed</h3><?php } ?> <?php if (is_wp_error($params['err'])) { ?> <p><em><strong>401 Not Authorized.</strong> This URL may require a username and password to access it.</em> You may want to add login credentials below and check it again.</p> <?php } ?> <div><label>Address: <input type="text" name="lookup" id="use-another-feed" placeholder="URL" <?php if (is_null($lookup)) { ?> value="URL" <?php } else { ?> value="<?php print esc_html($lookup); ?> " <?php } ?> size="64" style="max-width: 80%" /></label> <?php if (is_null($lookup)) { ?> <?php FeedWordPressSettingsUI::magic_input_tip_js('use-another-feed'); ?> <?php } ?> <?php $this->stamp_link_id('link_id'); ?> <input type="hidden" name="action" value="feedfinder" /> <input type="submit" class="button<?php if ($alt) { ?> -primary<?php } ?> " value="Check »" /></div> <?php $this->display_authentication_credentials_box(array('username' => $params['username'], 'password' => $params['password'], 'method' => $params['auth'])); ?> <p>This can be the address of a feed, or of a website. FeedWordPress will try to automatically detect any feeds associated with a website.</p> </div> <!-- class="inside" --> </fieldset></form> <?php }
function init() { global $fwp_path; // If this is a FeedWordPress admin page, queue up scripts for AJAX // functions that FWP uses. If it is a display page or a non-FWP admin // page, don't. wp_register_style('feedwordpress-elements', WP_PLUGIN_URL . '/' . $fwp_path . '/feedwordpress-elements.css'); if (FeedWordPressSettingsUI::is_admin()) { // For JavaScript that needs to be generated dynamically add_action('admin_print_scripts', array('FeedWordPressSettingsUI', 'admin_scripts')); // For CSS that needs to be generated dynamically. add_action('admin_print_styles', array('FeedWordPressSettingsUI', 'admin_styles')); wp_enqueue_style('dashboard'); wp_enqueue_style('feedwordpress-elements'); if (function_exists('wp_admin_css')) { wp_admin_css('css/dashboard'); } } $this->clear_cache_magic_url(); $this->update_magic_url(); }
/** * fix notice in 3.3 */ function fwp_scripts() { // If this is a FeedWordPress admin page, queue up scripts for AJAX functions that FWP uses // If it is a display page or a non-FeedWordPress admin page, don't. if (FeedWordPressSettingsUI::is_admin()) { add_action('admin_print_scripts', array('FeedWordPressSettingsUI', 'admin_scripts')); wp_register_style('feedwordpress-elements', A16Z_PLUGIN_URL . 'feedwordpress-elements.css'); wp_enqueue_style('dashboard'); wp_enqueue_style('feedwordpress-elements'); if (function_exists('wp_admin_css')) { if (fwp_test_wp_version(FWP_SCHEMA_25)) { wp_admin_css('css/dashboard'); } } } }
function open_sheet($header) { // Set up prepatory AJAX stuff ?> <script type="text/javascript"> <?php $this->ajax_interface_js(); ?> </script> <?php add_action(FeedWordPressCompatibility::bottom_script_hook($this->filename), array($this, 'fix_toggles'), 10000); FeedWordPressSettingsUI::ajax_nonce_fields(); ?> <div class="wrap feedwordpress-admin" id="feedwordpress-admin-<?php print $this->pageslug(); ?> "> <?php if (!is_null($header)) { $this->display_sheet_header($header); } if (!is_null($this->dispatch)) { ?> <form action="<?php print $this->form_action(); ?> " method="post"> <div><?php FeedWordPressCompatibility::stamp_nonce($this->dispatch); $this->stamp_link_id(); ?> </div> <?php } if ($this->has_link()) { $this->display_settings_scope_message(); } ?> <div class="tablenav"><?php if (!is_null($this->dispatch)) { ?> <div class="alignright"><?php $this->save_button(); ?> </div><?php } if ($this->has_link()) { $this->display_feed_select_dropdown(); } ?> </div> <div id="poststuff"> <?php }
function init() { global $fwp_path; // If this is a FeedWordPress admin page, queue up scripts for AJAX // functions that FWP uses. If it is a display page or a non-FWP admin // page, don't. wp_register_style('feedwordpress-elements', WP_PLUGIN_URL . '/' . $fwp_path . '/feedwordpress-elements.css'); if (FeedWordPressSettingsUI::is_admin()) { // For JavaScript that needs to be generated dynamically add_action('admin_print_scripts', array('FeedWordPressSettingsUI', 'admin_scripts')); // For CSS that needs to be generated dynamically. add_action('admin_print_styles', array('FeedWordPressSettingsUI', 'admin_styles')); wp_enqueue_style('dashboard'); wp_enqueue_style('feedwordpress-elements'); /*if (function_exists('wp_admin_css')) : wp_admin_css('css/dashboard'); endif;*/ } // This is a special post status for hiding posts that have expired register_post_status('fwpretired', array('label' => _x('Retired', 'post'), 'label_count' => _n_noop('Retired <span class="count">(%s)</span>', 'Retired <span class="count">(%s)</span>'), 'exclude_from_search' => true, 'public' => false, 'publicly_queryable' => false, 'show_in_admin_all_list' => false, 'show_in_admin_status_list' => true)); add_action('template_redirect', array($this, 'redirect_retired'), -100); add_action('wp_ajax_fwp_feeds', array($this, 'fwp_feeds')); add_action('wp_ajax_fwp_feedcontents', array($this, 'fwp_feedcontents')); add_action('wp_ajax_fwp_xpathtest', array($this, 'fwp_xpathtest')); $this->clear_cache_magic_url(); $this->update_magic_url(); }
function form_input_tip($page, $limit) { FeedWordPressSettingsUI::magic_input_tip_js('.form-input-tip'); }
function display_alt_feed_box($lookup, $alt = false) { global $fwp_post; ?> <form action="admin.php?page=<?php echo FWP_FEEDS_PAGE_SLUG; ?> " method="post"> <div class="inside"><?php FeedWordPressCompatibility::stamp_nonce(get_class($this)); ?> <fieldset class="alt" <?php if (!$alt) { ?> style="margin: 1.0em 3.0em; font-size: smaller;"<?php } ?> > <legend><?php if ($alt) { ?> Alternative feeds<?php } else { ?> Find feeds<?php } ?> </legend> <?php if ($alt) { ?> <h3>Use a different feed</h3><?php } ?> <div><label>Address: <input type="text" name="lookup" id="use-another-feed" placeholder="URL" <?php if (is_null($lookup)) { ?> value="URL" <?php } else { ?> value="<?php print esc_html($lookup); ?> " <?php } ?> size="64" style="max-width: 80%" /></label> <?php if (is_null($lookup)) { ?> <?php FeedWordPressSettingsUI::magic_input_tip_js('use-another-feed'); ?> <?php } ?> <?php $this->stamp_link_id('link_id'); ?> <input type="hidden" name="action" value="feedfinder" /> <input type="submit" class="button<?php if ($alt) { ?> -primary<?php } ?> " value="Check »" /></div> <p>This can be the address of a feed, or of a website. FeedWordPress will try to automatically detect any feeds associated with a website.</p> </div> <!-- class="inside" --> </fieldset></form> <?php }
function fwp_authors_page() { global $wp_db_version; if (FeedWordPress::needs_upgrade()) { fwp_upgrade_page(); return; } FeedWordPressCompatibility::validate_http_request('feedwordpress_author_settings', 'manage_links'); $link = FeedWordPressAdminPage::submitted_link(); $authorsPage = new FeedWordPressAuthorsPage($link); $mesg = null; if (isset($GLOBALS['fwp_post']['fix_mismatch'])) { $fix_mismatch_to_id = $GLOBALS['fwp_post']['fix_mismatch_to']; $fix_mismatch_from_id = (int) $GLOBALS['fwp_post']['fix_mismatch_from']; if (is_numeric($fix_mismatch_from_id)) { // Make a list of all the items by this author syndicated from this feed... $args = array('posts_per_page' => -1, 'meta_key' => 'syndication_feed_id', 'meta_value' => $link->id, 'post_author' => $fix_mismatch_from_id); $query = new WP_Query($args); $mesg = ''; $post_ids = array(); if ($query->have_posts()) { while ($query->have_posts()) { global $post; $query->the_post(); if (is_numeric($fix_mismatch_to_id)) { $post->post_author = $fix_mismatch_to_id; $new_post = (array) $post; wp_insert_post($new_post); $mesg_action = 'Re-assigned'; $post_ids[] = get_the_ID(); } else { if ($fix_mismatch_to_id == 'filter') { wp_delete_post($post->ID); $mesg_action = 'Re-assigned'; $post_ids[] = get_the_ID(); } } } $mesg = $mesg_action . ' ' . count($post_ids) . ' post' . (count($post_ids) == 1 ? '' : 's') . '.'; } else { $mesg = "Couldn't find any posts that matched your criteria."; } } $updated_link = false; } elseif (isset($GLOBALS['fwp_post']['save'])) { if (is_object($link) and $link->found()) { $alter = array(); // Unfamiliar author rule if (isset($GLOBALS['fwp_post']["unfamiliar_author"])) { if ('site-default' == $GLOBALS['fwp_post']["unfamiliar_author"]) { unset($link->settings["unfamiliar author"]); } else { $link->settings["unfamiliar author"] = $GLOBALS['fwp_post']["unfamiliar_author"]; } } // Handle author mapping rules if (isset($GLOBALS['fwp_post']['author_rules_name']) and isset($GLOBALS['fwp_post']['author_rules_action'])) { unset($link->settings['map authors']); foreach ($GLOBALS['fwp_post']['author_rules_name'] as $key => $name) { // Normalize for case and whitespace $name = strtolower(trim($name)); $author_action = strtolower(trim($GLOBALS['fwp_post']['author_rules_action'][$key])); if (strlen($name) > 0) { $link->settings['map authors']['name'][$name] = $author_action; } } } if (isset($GLOBALS['fwp_post']['add_author_rule_name']) and isset($GLOBALS['fwp_post']['add_author_rule_action'])) { $name = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_name'])); $author_action = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_action'])); if (strlen($name) > 0) { $link->settings['map authors']['name'][$name] = $author_action; } } // Save settings $link->save_settings(true); $updated_link = true; // Reset, reload $link_id = $link->id; unset($link); $link = new SyndicatedLink($link_id); } else { update_option('feedwordpress_unfamiliar_author', $GLOBALS['fwp_post']['unfamiliar_author']); if (isset($GLOBALS['fwp_post']['match_author_by_email']) and $GLOBALS['fwp_post']['match_author_by_email'] == 'yes') { update_option('feedwordpress_do_not_match_author_by_email', 'no'); } else { update_option('feedwordpress_do_not_match_author_by_email', 'yes'); } if (isset($GLOBALS['fwp_post']['null_emails'])) { update_option('feedwordpress_null_email_set', $GLOBALS['fwp_post']['null_emails']); } $updated_link = true; } do_action('feedwordpress_admin_page_authors_save', $GLOBALS['fwp_post'], $authorsPage); $authorsPage->refresh_author_list(); } else { $updated_link = false; } //////////////////////////////////////////////// // Prepare settings page /////////////////////// //////////////////////////////////////////////// if ($updated_link) { ?> <div class="updated"><p>Syndicated author settings updated.</p></div> <?php } elseif (!is_null($mesg)) { ?> <div class="updated"><p><?php print esc_html($mesg); ?> </p></div> <?php } if (function_exists('add_meta_box')) { add_action(FeedWordPressCompatibility::bottom_script_hook(__FILE__), array($authorsPage, 'fix_toggles'), 10000); FeedWordPressSettingsUI::ajax_nonce_fields(); } $authorsPage->open_sheet('Syndicated Author'); ?> <div id="post-body"> <?php //////////////////////////////////////////////// // Display settings boxes ////////////////////// //////////////////////////////////////////////// $boxes_by_methods = array('syndicated_authors_box' => __('Syndicated Authors'), 'fix_authors_box' => __('Reassign Authors')); if ($authorsPage->for_default_settings()) { unset($boxes_by_methods['fix_authors_box']); } foreach ($boxes_by_methods as $method => $row) { if (is_array($row)) { $id = $row['id']; $title = $row['title']; } else { $id = 'feedwordpress_' . $method; $title = $row; } fwp_add_meta_box($id, $title, array('FeedWordPressAuthorsPage', $method), $authorsPage->meta_box_context(), $authorsPage->meta_box_context()); } do_action('feedwordpress_admin_page_authors_meta_boxes', $authorsPage); ?> <div class="metabox-holder"> <?php fwp_do_meta_boxes($authorsPage->meta_box_context(), $authorsPage->meta_box_context(), $authorsPage); ?> </div> <!-- class="metabox-holder" --> </div> <!-- id="post-body" --> <?php $authorsPage->close_sheet(); ?> <script type="text/javascript"> <?php if (!is_object($link) or !$link->found()) { ?> contextual_appearance('match-author-by-email', 'unless-null-email', null, 'yes', 'block', /*checkbox=*/ true); <?php } ?> </script> <?php }
function fwp_syndication_manage_page_links_box($object = NULL, $box = NULL) { $links = FeedWordPress::syndicated_links(array("hide_invisible" => false)); $sources = $object->sources('*'); $visibility = $object->visibility_toggle(); $showInactive = $object->show_inactive(); $hrefPrefix = 'admin.php?page=' . FWP_SYNDICATION_PAGE_SLUG; ?> <form id="syndicated-links" action="<?php print $hrefPrefix; ?> &visibility=<?php print $visibility; ?> " method="post"> <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> </div> <?php if (count($sources[$visibility]) > 0) { fwp_syndication_manage_page_links_subsubsub($sources, $showInactive); } if ($showInactive) { ?> <p style="clear: both; font-size: smaller; font-style: italic">FeedWordPress used to syndicate posts from these sources, but you have unsubscribed from them.</p> <?php } ?> <div class="tablenav"> <div class="alignright"> <label for="add-uri">New source:</label> <input type="text" name="lookup" id="add-uri" value="Website or feed URI" /> <?php FeedWordPressSettingsUI::magic_input_tip_js('add-uri'); ?> <input type="hidden" name="action" value="feedfinder" /> <input type="submit" class="button-secondary" name="action" value="<?php print FWP_SYNDICATE_NEW; ?> " /></div> <?php if (count($sources[$visibility]) > 0) { ?> <div class="alignleft"> <?php if ($showInactive) { ?> <input class="button-secondary" type="submit" name="action" value="<?php print FWP_RESUB_CHECKED; ?> " /> <input class="button-secondary" type="submit" name="action" value="<?php print FWP_DELETE_CHECKED; ?> " /> <?php } else { ?> <input class="button-secondary" type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?> " /> <input class="button-secondary delete" type="submit" name="action" value="<?php print FWP_UNSUB_CHECKED; ?> " /> <?php } ?> </div> <?php } else { ?> <?php fwp_syndication_manage_page_links_subsubsub($sources, $showInactive); } ?> <br class="clear" /> </div> <br class="clear" /> <?php fwp_syndication_manage_page_links_table_rows($sources[$visibility], $visibility); ?> </form> <?php }
function open_sheet($header) { // Set up prepatory AJAX stuff $this->ajax_interface_js(); if (function_exists('add_meta_box')) { add_action(FeedWordPressCompatibility::bottom_script_hook($this->filename), array($this, 'fix_toggles'), 10000); FeedWordPressSettingsUI::ajax_nonce_fields(); } ?> <div class="wrap" style="position:relative"> <?php if (!is_null($header)) { $this->display_sheet_header($header); } if (!is_null($this->dispatch)) { ?> <form action="admin.php?page=<?php echo $this->filename; ?> " method="post"> <div><?php FeedWordPressCompatibility::stamp_nonce($this->dispatch); $this->stamp_link_id(); ?> </div> <?php } if ($this->has_link()) { $this->display_feed_select_dropdown(); $this->display_settings_scope_message(); } if (function_exists('do_meta_boxes')) { ?> <div id="poststuff"> <?php } else { ?> </div> <!-- class="wrap" --> <?php } if (!is_null($this->dispatch)) { fwp_settings_form_single_submit(); } }