Example #1
0
function wpmc_admin_init()
{
    if (isset($_POST) && isset($_POST['wpmc_pro'])) {
        wpmc_validate_pro($_POST['wpmc_pro']['subscr_id']);
    }
    $pro_status = get_option('wpmc_pro_status', "Not Pro.");
    require 'wpmc_class.settings-api.php';
    global $wpmc_settings_api;
    $wpmc_settings_api = new WeDevs_Settings_API();
    $sections = array(array('id' => 'wpmc_basics', 'title' => __('Options', 'media-file-cleaner')), array('id' => 'wpmc_pro', 'title' => __('Serial Key (Pro)', 'media-file-cleaner')));
    global $shortcode_tags;
    $allshortcodes = array_diff($shortcode_tags, array());
    $my_shortcodes = array();
    foreach ($allshortcodes as $sc) {
        if ($sc != '__return_false') {
            array_push($my_shortcodes, str_replace('_shortcode', '', (string) $sc));
        }
    }
    $my_shortcodes = implode(', ', $my_shortcodes);
    $fields = array('wpmc_basics' => array(array('name' => 'scan_media', 'label' => __('Scan Media', 'media-file-cleaner'), 'desc' => __('The Media Library will be scanned.<br /><small>The medias from Media Library which seem not being used in your WordPress will be marked as to be deleted.</small>', 'media-file-cleaner'), 'type' => 'checkbox', 'default' => false), array('name' => 'scan_files', 'label' => __('Scan Files', 'media-file-cleaner'), 'desc' => __('The Uploads folder will be scanned.<br /><small>The files in your /uploads folder that don\'t seem being used in your WordPress will be marked as to be deleted. <b>If they are found in your Media Library, they will be considered as fine.</b></small>', 'media-file-cleaner'), 'type' => 'checkbox', 'default' => false), array('name' => 'shortcode', 'label' => __('Resolve Shortcode', 'media-file-cleaner'), 'desc' => sprintf(__('The shortcodes you are using in your posts and widgets will be resolved and checked.<br /><small>This process takes more resources. If the scanning suddenly stops, this might be the cause. Here is the list of the shortcodes enabled on your WordPress that you might be using: <b>%s</b>. Please note that the gallery shortcode is checked by the normal process. You don\'t need to have this option enabled for the WP gallery.</small>', 'media-file-cleaner'), $my_shortcodes), 'type' => 'checkbox', 'default' => false), array('name' => 'scan_non_ascii', 'label' => __('UTF-8 Support', 'media-file-cleaner'), 'desc' => __('The filenames in UTF-8 will not be skipped.<br /><small>PHP does not always work well with UTF-8 on all systems (Windows?). If the scanning suddenly stops, this might be the cause.</small>', 'media-file-cleaner'), 'type' => 'checkbox', 'default' => false), array('name' => 'hide_thumbnails', 'label' => __('Hide Thumbnails', 'media-file-cleaner'), 'desc' => __('Hide the thumbnails column.<br /><small>Useful if your WordPress if filled-up with huge images.</small>', 'media-file-cleaner'), 'type' => 'checkbox', 'default' => false)), 'wpmc_pro' => array(array('name' => 'pro', 'label' => '', 'desc' => sprintf(__("Status: %s", 'media-file-cleaner'), $pro_status), 'type' => 'html'), array('name' => 'subscr_id', 'label' => __('Serial', 'media-file-cleaner'), 'desc' => __('<br />Enter your serial or subscription ID here. If you don\'t have one yet, get one <a target="_blank" href="http://apps.meow.fr/media-file-cleaner/">right here</a>.', 'media-file-cleaner'), 'type' => 'text', 'default' => "")));
    $wpmc_settings_api->set_sections($sections);
    $wpmc_settings_api->set_fields($fields);
    $wpmc_settings_api->admin_init();
}
/**
 *
 * PRO
 * Come on, it's not so expensive :'(
 *
 */
function wpmc_is_pro()
{
    $validated = get_transient('wpmc_validated');
    if ($validated) {
        $serial = get_option('wpmc_pro_serial');
        return !empty($serial);
    }
    $subscr_id = get_option('wpmc_pro_serial', "");
    if (!empty($subscr_id)) {
        return wpmc_validate_pro(wpmc_getoption("subscr_id", "wpmc_pro", array()));
    }
    return false;
}