コード例 #1
0
function ep_update_exclusions($post_ID)
{
    // Bang (!) to reverse the polarity of the boolean, turning include into exclude
    $exclude_this_page = !(bool) @$_POST['ep_this_page_included'];
    // SWTODO: Also check for a hidden var, which confirms that this checkbox was present
    // If hidden var not present, then default to including the page in the nav (i.e. bomb out here rather
    // than add the page ID to the list of IDs to exclude)
    $ctrl_present = (bool) @$_POST['ep_ctrl_present'];
    if (!$ctrl_present) {
        return;
    }
    $excluded_ids = ep_get_excluded_ids();
    // If we need to EXCLUDE the page from the navigation...
    if ($exclude_this_page) {
        // Add the post ID to the array of excluded IDs
        array_push($excluded_ids, $post_ID);
        // De-dupe the array, in case it was there already
        $excluded_ids = array_unique($excluded_ids);
    }
    // If we need to INCLUDE the page in the navigation...
    if (!$exclude_this_page) {
        // Find the post ID in the array of excluded IDs
        $index = array_search($post_ID, $excluded_ids);
        // Delete any index found
        if ($index !== false) {
            unset($excluded_ids[$index]);
        }
    }
    $excluded_ids_str = implode(EP_OPTION_SEP, $excluded_ids);
    ep_set_option(EP_OPTION_NAME, $excluded_ids_str);
}
コード例 #2
0
/**
 * SACK response function for toggling page exclusion status
 *
 * @since 2.1.0
 * @author scripts@schloebe.de
 * @link http://plugins.trac.wordpress.org/browser/exclude-pages/trunk/exclude_pages.php#L162
 */
function ame_toggle_excludestatus()
{
    $pageid = intval($_POST['pageid']);
    $statusid = intval($_POST['statusid']);
    $excluded_ids = ep_get_excluded_ids();
    if ($statusid == 1) {
        array_push($excluded_ids, $pageid);
        $excluded_ids = array_unique($excluded_ids);
    } else {
        $index = array_search($pageid, $excluded_ids);
        if ($index !== false) {
            unset($excluded_ids[$index]);
        }
    }
    $excluded_ids_str = implode(',', $excluded_ids);
    ep_set_option(EP_OPTION_NAME, $excluded_ids_str, "Comma separated list of post and page IDs to exclude when returning pages from the get_pages function.");
    if ($statusid == 0) {
        $e_status = 1;
        $e_img = '_off';
    } else {
        $e_status = 0;
        $e_img = '';
    }
    die("jQuery('#excludepagewrap{$pageid}').html('<a tip=\"" . __('Plugin: Exclude Pages - Exclude page from navigation', 'admin-management-xtended') . "\" href=\"javascript:void(0);\" onclick=\"ame_ajax_set_excludestatus(\\'" . $pageid . "\\', \\'" . $e_status . "\\');return false;\"><img src=\"" . AME_PLUGINFULLURL . "img/" . AME_IMGSET . "excludepages" . $e_img . ".gif\" border=\"0\" alt=\"" . __('Plugin: Exclude Pages - Exclude page from navigation', 'admin-management-xtended') . "\" title=\"" . __('Plugin: Exclude Pages - Exclude page from navigation', 'admin-management-xtended') . "\" /></a>');jQuery('#page-" . $pageid . " td, #page-" . $pageid . " th').animate( { backgroundColor: '#EAF3FA' }, 300).animate( { backgroundColor: '#F9F9F9' }, 300).animate( { backgroundColor: '#EAF3FA' }, 300).animate( { backgroundColor: '#F9F9F9' }, 300);");
}