Пример #1
0
function wp_insert_legal_filter_the_content($content)
{
    $options = get_option('wp_insert_legal_options');
    $page_details = wp_insert_get_page_details();
    if (in_array($page_details['ID'], explode(',', $options['privacy-policy']['pages']))) {
        return $options['privacy-policy']['content'];
    } else {
        if (in_array($page_details['ID'], explode(',', $options['terms-and-conditions']['pages']))) {
            return $options['terms-and-conditions']['content'];
        }
    }
    if (in_array($page_details['ID'], explode(',', $options['disclaimer']['pages']))) {
        return $options['disclaimer']['content'];
    }
    if (in_array($page_details['ID'], explode(',', $options['copyright-notice']['pages']))) {
        return $options['copyright-notice']['content'];
    }
    return $content;
}
Пример #2
0
function wp_insert_get_ad_status($rules)
{
    if (!isset($rules)) {
        return false;
    }
    $rules = wp_insert_sanitize_array($rules, array('status', 'rules_exclude_home', 'rules_home_instances', 'rules_exclude_archives', 'rules_archives_instances', 'rules_exclude_categories', 'rules_categories_exceptions', 'rules_categories_instances', 'rules_exclude_search', 'rules_search_instances', 'rules_exclude_page', 'rules_page_exceptions', 'rules_exclude_post', 'rules_post_exceptions'));
    if (!$rules['status']) {
        return false;
    }
    global $wpInsertPostInstance;
    $page_details = wp_insert_get_page_details();
    switch ($page_details['type']) {
        case 'HOME':
            if ($rules['rules_exclude_home']) {
                return false;
            } else {
                if ($rules['rules_home_instances'] && in_array($wpInsertPostInstance, split(',', $rules['rules_home_instances']))) {
                    return false;
                }
            }
            break;
        case 'ARCHIVE':
            if ($rules['rules_exclude_archives']) {
                return false;
            } else {
                if ($rules['rules_archives_instances'] && in_array($wpInsertPostInstance, split(',', $rules['rules_archives_instances']))) {
                    return false;
                }
            }
            break;
        case 'CATEGORY':
            if ($rules['rules_exclude_categories']) {
                return false;
            } else {
                if ($rules['rules_categories_exceptions'] && in_array($page_details['ID'], split(',', $rules['rules_categories_exceptions']))) {
                    return false;
                } else {
                    if ($rules['rules_categories_instances'] && in_array($wpInsertPostInstance, split(',', $rules['rules_categories_instances']))) {
                        return false;
                    }
                }
            }
            break;
        case 'SEARCH':
            if ($rules['rules_exclude_search']) {
                return false;
            } else {
                if ($rules['rules_search_instances'] && in_array($wpInsertPostInstance, split(',', $rules['rules_search_instances']))) {
                    return false;
                }
            }
            break;
        case 'PAGE':
            if ($rules['rules_exclude_page']) {
                return false;
            } else {
                if ($rules['rules_page_exceptions'] && in_array($page_details['ID'], split(',', $rules['rules_page_exceptions']))) {
                    return false;
                }
            }
            break;
        case 'POST':
            if ($rules['rules_exclude_post']) {
                return false;
            } else {
                if ($rules['rules_post_exceptions'] && in_array($page_details['ID'], split(',', $rules['rules_post_exceptions']))) {
                    return false;
                } else {
                    if ($rules['rules_categories_post_exceptions'] && is_array($page_details['categories']) && count(array_intersect(array_unique($page_details['categories']), array_unique(split(',', $rules['rules_categories_post_exceptions'])))) > 0) {
                        return false;
                    }
                }
            }
            break;
        case 'CUSTOM':
            if ($rules['rules_exclude_cpt_' . $page_details['type_name']]) {
                return false;
            }
            break;
    }
    return true;
}