Example #1
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;
    }
}
 public function admin_tools()
 {
     if (!empty($_POST['cp_tools']['flush_cache'])) {
         $message = cp_flush_all_cache();
         echo scb_admin_notice($message);
     }
     if (!empty($_POST['cp_tools']['delete_tables'])) {
         cp_delete_db_tables();
     }
     if (!empty($_POST['cp_tools']['delete_options'])) {
         cp_delete_all_options();
     }
     if (!empty($_POST['cp_tools']['rerun_migration'])) {
         update_option('cp_tools_run_convertToCustomPostType', 'no');
         $message = cp_convert_posts2Ads();
         echo scb_admin_notice($message);
     }
 }