Пример #1
0
 public function admin_tools()
 {
     if (isset($_GET['pruneads']) && $_GET['pruneads'] == 1) {
         cp_check_expired_cron();
         echo scb_admin_notice(__('Expired ads have been pruned.', APP_TD));
     }
     if (isset($_GET['resetstats']) && $_GET['resetstats'] == 1) {
         appthemes_reset_stats();
         echo scb_admin_notice(__('Statistics have been reseted.', APP_TD));
     }
     // flush out the cache so changes can be visible
     cp_flush_all_cache();
 }
Пример #2
0
function cp_update_options($options)
{
    $toolsMessage = '';
    if (isset($_POST['submitted']) && $_POST['submitted'] == 'yes') {
        foreach ($options as $value) {
            if (isset($_POST[$value['id']])) {
                // allow fields with just space, don't trim value
                if (in_array($value['id'], array('cp_thousands_separator'))) {
                    update_option($value['id'], stripslashes($_POST[$value['id']]));
                } else {
                    update_option($value['id'], appthemes_clean($_POST[$value['id']]));
                }
            } else {
                @delete_option($value['id']);
            }
        }
        // do a separate update for price per cats since it's not in the $options array
        if (isset($_POST['catarray'])) {
            foreach ($_POST['catarray'] as $key => $value) {
                update_option($key, appthemes_clean($value));
            }
        }
        // clean all values from the post and store them into a wordpress option as a serialized array of cat ID's
        if (isset($_POST['catreqarray'])) {
            foreach ($_POST['catreqarray'] as $key => $value) {
                $catreqarray[absint($value)] = '';
            }
            update_option('cp_required_categories', $catreqarray);
        } else {
            if (isset($_POST['cp_required_membership_type'])) {
                delete_option('cp_required_categories');
            }
        }
        if (get_option('cp_tools_run_expiredcheck') == 'yes') {
            update_option('cp_tools_run_expiredcheck', 'no');
            cp_check_expired_cron();
            $toolsMessage = '';
            $toolsMessage .= __('Ads Expired Check was executed.', APP_TD);
        }
        // flush out the cache so changes can be visible
        cp_flush_all_cache();
        echo '<div class="updated"><p>' . __('Your settings have been saved.', APP_TD) . ' ' . $toolsMessage . '</p></div>';
    } elseif (isset($_POST['submitted']) && $_POST['submitted'] == 'convertToCustomPostType') {
        update_option('cp_tools_run_convertToCustomPostType', 'no');
        $toolsMessage .= cp_convert_posts2Ads();
        echo $toolsMessage;
    }
}