/** * Constructs the Feeds page object * * @param mixed $link An object of class {@link SyndicatedLink} if created for one feed's settings, NULL if created for global default settings */ function FeedWordPressFeedsPage($link = -1) { if (is_numeric($link) and -1 == $link) { $link = FeedWordPressAdminPage::submitted_link(); } FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpressfeeds', $link); $this->dispatch = get_class($this); $this->filename = FWP_FEEDS_PAGE_SLUG; $this->updatedPosts = new UpdatedPostsControl($this); }
/** * Construct the posts page object. * * @param mixed $link An object of class {@link SyndicatedLink} if created for one feed's settings, NULL if created for global default settings */ function FeedWordPressPostsPage($link = -1) { if (is_numeric($link) and -1 == $link) { $link = FeedWordPressAdminPage::submitted_link(); } FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpresspostspage', $link); $this->dispatch = 'feedwordpress_admin_page_posts'; $this->filename = __FILE__; $this->updatedPosts = new UpdatedPostsControl($this); $this->pagenames = array('default' => 'Posts', 'settings-update' => 'Syndicated posts', 'open-sheet' => 'Syndicated Posts & Links'); }
function FeedWordPressAuthorsPage($link = -1) { if (is_numeric($link) and -1 == $link) { $link = FeedWordPressAdminPage::submitted_link(); } FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpressauthors', $link); $this->refresh_author_list(); $this->dispatch = 'feedwordpress_author_settings'; $this->filename = __FILE__; $this->pagenames = array('default' => 'Authors', 'settings-update' => 'Syndicated Authors', 'open-sheet' => 'Syndicated Author'); }
/** * Constructs the Feeds page object * * @param mixed $link An object of class {@link SyndicatedLink} if created for one feed's settings, NULL if created for global default settings */ function FeedWordPressFeedsPage($link = -1) { if (is_numeric($link) and -1 == $link) { $link = FeedWordPressAdminPage::submitted_link(); } FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpressfeeds', $link); $this->dispatch = 'feedwordpress_admin_page_feeds'; $this->pagenames = array('default' => 'Feeds', 'settings-update' => 'Syndicated feed', 'open-sheet' => 'Feed and Update'); $this->filename = __FILE__; $this->updatedPosts = new UpdatedPostsControl($this); $this->special_settings = apply_filters('syndicated_feed_special_settings', $this->special_settings, $this); }
function fwp_posts_page() { global $wp_db_version; global $fwp_post; if (FeedWordPress::needs_upgrade()) { fwp_upgrade_page(); return; } // If this is a POST, validate source and user credentials FeedWordPressCompatibility::validate_http_request('feedwordpress_posts_settings', 'manage_links'); $link = FeedWordPressAdminPage::submitted_link(); $postsPage = new FeedWordPressPostsPage($link); $mesg = null; //////////////////////////////////////////////// // Process POST request, if any //////////////// //////////////////////////////////////////////// if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') { $postsPage->accept_POST($fwp_post); do_action('feedwordpress_admin_page_posts_save', $fwp_post, $postsPage); } $postsPage->ajax_interface_js(); if ($postsPage->updated) { ?> <div class="updated"><p>Syndicated posts settings updated.</p></div> <?php } elseif (!is_null($mesg)) { ?> <div class="updated"><p><?php print esc_html($mesg); ?> </p></div> <?php } ?> <?php $links = FeedWordPress::syndicated_links(); $postsPage->open_sheet('Syndicated Posts & Links'); ?> <style type="text/css"> table.edit-form th, table.form-table th { width: 27%; vertical-align: top; } table.edit-form td, table.form-table td { width: 73%; vertical-align: top; } ul.options { margin: 0; padding: 0; list-style: none; } </style> <div id="post-body"> <?php $boxes_by_methods = array('publication_box' => __('Syndicated Posts'), 'links_box' => __('Links'), 'formatting_box' => __('Formatting'), 'comments_and_pings_box' => __('Comments & Pings'), 'custom_post_settings_box' => __('Custom Post Settings (to apply to each syndicated post)')); foreach ($boxes_by_methods as $method => $title) { fwp_add_meta_box('feedwordpress_' . $method, $title, array('FeedWordPressPostsPage', $method), $postsPage->meta_box_context(), $postsPage->meta_box_context()); } do_action('feedwordpress_admin_page_posts_meta_boxes', $postsPage); ?> <div class="metabox-holder"> <?php fwp_do_meta_boxes($postsPage->meta_box_context(), $postsPage->meta_box_context(), $postsPage); ?> </div> <!-- class="metabox-holder" --> </div> <!-- id="post-body" --> <?php $postsPage->close_sheet(); }
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_categories_page() { global $wp_db_version; if (FeedWordPress::needs_upgrade()) { fwp_upgrade_page(); return; } FeedWordPressCompatibility::validate_http_request('feedwordpress_categories_settings', 'manage_links'); $link = FeedWordPressAdminPage::submitted_link(); $catsPage = new FeedWordPressCategoriesPage($link); $mesg = null; //////////////////////////////////////////////// // Process POST request, if any ///////////////// //////////////////////////////////////////////// if (isset($GLOBALS['fwp_post']['save']) or isset($GLOBALS['fwp_post']['submit'])) { $saveCats = array(); if (isset($GLOBALS['fwp_post']['post_category'])) { foreach ($GLOBALS['fwp_post']['post_category'] as $cat_id) { $saveCats[] = '{#' . $cat_id . '}'; } } // Different variable names to cope with different WordPress AJAX UIs $syndicatedTags = array(); if (isset($GLOBALS['fwp_post']['tax_input']['post_tag'])) { $syndicatedTags = explode(",", $GLOBALS['fwp_post']['tax_input']['post_tag']); } elseif (isset($GLOBALS['fwp_post']['tags_input'])) { $syndicatedTags = explode(",", $GLOBALS['fwp_post']['tags_input']); } $syndicatedTags = array_map('trim', $syndicatedTags); if (is_object($link) and $link->found()) { $alter = array(); // Categories if (!empty($saveCats)) { $link->settings['cats'] = $saveCats; } else { unset($link->settings['cats']); } // Tags $link->settings['tags'] = $syndicatedTags; // Unfamiliar categories if (isset($GLOBALS['fwp_post']["unfamiliar_category"])) { if ('site-default' == $GLOBALS['fwp_post']["unfamiliar_category"]) { unset($link->settings["unfamiliar category"]); } else { $link->settings["unfamiliar category"] = $GLOBALS['fwp_post']["unfamiliar_category"]; } } // Category spitting regex if (isset($GLOBALS['fwp_post']['cat_split'])) { if (strlen(trim($GLOBALS['fwp_post']['cat_split'])) > 0) { $link->settings['cat_split'] = trim($GLOBALS['fwp_post']['cat_split']); } else { unset($link->settings['cat_split']); } } // Save settings $link->save_settings(true); $catsPage->updated = true; // Reset, reload $link_id = $link->id; unset($link); $link = new SyndicatedLink($link_id); } else { // Categories if (!empty($saveCats)) { update_option('feedwordpress_syndication_cats', implode(FEEDWORDPRESS_CAT_SEPARATOR, $saveCats)); } else { delete_option('feedwordpress_syndication_cats'); } // Tags if (!empty($syndicatedTags)) { update_option('feedwordpress_syndication_tags', implode(FEEDWORDPRESS_CAT_SEPARATOR, $syndicatedTags)); } else { delete_option('feedwordpress_syndication_tags'); } update_option('feedwordpress_unfamiliar_category', $_REQUEST['unfamiliar_category']); $catsPage->updated = true; } do_action('feedwordpress_admin_page_categories_save', $GLOBALS['fwp_post'], $catsPage); } else { $catsPage->updated = false; } //////////////////////////////////////////////// // Prepare settings page /////////////////////// //////////////////////////////////////////////// $catsPage->display_update_notice_if_updated('Syndicated categories' . FEEDWORDPRESS_AND_TAGS, $mesg); $catsPage->open_sheet('Categories' . FEEDWORDPRESS_AND_TAGS); ?> <style type="text/css"> table.edit-form th { width: 27%; vertical-align: top; } table.edit-form td { width: 73%; vertical-align: top; } table.edit-form td ul.options { margin: 0; padding: 0; list-style: none; } </style> <div id="post-body"> <?php //////////////////////////////////////////////// // Display settings boxes ////////////////////// //////////////////////////////////////////////// $boxes_by_methods = array('feed_categories_box' => __('Feed Categories' . FEEDWORDPRESS_AND_TAGS), 'categories_box' => array('title' => __('Categories'), 'id' => 'categorydiv'), 'tags_box' => __('Tags')); if (!FeedWordPressCompatibility::post_tags()) { unset($boxes_by_methods['tags_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('FeedWordPressCategoriesPage', $method), $catsPage->meta_box_context(), $catsPage->meta_box_context()); } do_action('feedwordpress_admin_page_categories_meta_boxes', $catsPage); ?> <div class="metabox-holder"> <?php fwp_do_meta_boxes($catsPage->meta_box_context(), $catsPage->meta_box_context(), $catsPage); ?> </div> <!-- class="metabox-holder" --> </div> <!-- id="post-body" --> <?php $catsPage->close_sheet(); }