function motopressCEInit()
{
    global $motopressCESettings;
    wp_register_style('mpce-style', $motopressCESettings['plugin_dir_url'] . 'includes/css/style.css', array(), $motopressCESettings['plugin_version']);
    wp_register_script('mpce-detect-browser', $motopressCESettings['plugin_dir_url'] . 'mp/core/detectBrowser/detectBrowser.js', array(), $motopressCESettings['plugin_version']);
    wp_enqueue_script('mpce-detect-browser');
    //new MPCEAutoUpdate($motopressCESettings['plugin_version'], $motopressCESettings['update_url'], $motopressCESettings['plugin_name'].'/'.$motopressCESettings['plugin_name'].'.php');
    //add_action('in_plugin_update_message-'.$motopressCESettings['plugin_name'].'/'.$motopressCESettings['plugin_name'].'.php', 'motopressCEAddUpgradeMessageLink', 20, 2);
    $isDisableUpdater = apply_filters('mpce_disable_updater', false);
    if (!$isDisableUpdater) {
        new EDD_MPCE_Plugin_Updater($motopressCESettings['edd_mpce_store_url'], __FILE__, array('version' => $motopressCESettings['plugin_version'], 'license' => get_option('edd_mpce_license_key'), 'item_name' => $motopressCESettings['edd_mpce_item_name'], 'author' => $motopressCESettings['plugin_author']));
    }
    motopressCERegisterHtmlAttributes();
    if (!is_array(get_option('motopress_google_font_classes'))) {
        add_action('admin_notices', 'motopress_google_font_not_writable_notice');
        $fontClasses = array('opensans' => array('family' => 'Open Sans', 'variants' => array('300', 'regular', '700')));
        saveGoogleFontClasses($fontClasses);
    }
}
Ejemplo n.º 2
0
function motopressCESettingsSave()
{
    if (!empty($_POST)) {
        global $motopressCESettings;
        // Language
        if (isset($_POST['language']) && !empty($_POST['language'])) {
            $language = $_POST['language'];
            update_option('motopress-language', $language);
            $motopressCESettings['lang'] = motopressCEGetLang();
        }
        // AutoSave
        if (isset($_POST['autosave_autodraft'])) {
            $autosave = '1';
        } else {
            $autosave = '0';
        }
        update_option('motopress-ce-autosave-autodraft', $autosave);
        // Spellcheck
        if (isset($_POST['spellcheck_enable'])) {
            $spellcheck_enable = '1';
        } else {
            $spellcheck_enable = '0';
        }
        update_option('motopress-ce-spellcheck-enable', $spellcheck_enable);
        // Custom CSS
        if (isset($_POST['custom_css'])) {
            if (!file_exists($motopressCESettings['motopress_upload_dir'])) {
                mkdir($motopressCESettings['motopress_upload_dir'], 0777);
            }
            $current_css = $_POST['custom_css'];
            // css file creation & rewrite
            if (!empty($current_css)) {
                $content = stripslashes($current_css);
                clearstatcache();
                if (is_writable($motopressCESettings['wp_upload_dir'])) {
                    file_put_contents($motopressCESettings['custom_css_file_path'], $content);
                }
            } else {
                if (file_exists($motopressCESettings['custom_css_file_path'])) {
                    clearstatcache();
                    if (is_writable($motopressCESettings['wp_upload_dir'])) {
                        unlink($motopressCESettings['custom_css_file_path']);
                    }
                }
            }
            // css file deletion END
        }
        // Excerpt shortcode
        if (isset($_POST['excerpt_shortcode']) && $_POST['excerpt_shortcode']) {
            $excerptShortcode = '1';
        } else {
            $excerptShortcode = '0';
        }
        update_option('motopress-ce-excerpt-shortcode', $excerptShortcode);
        // Save excerpt
        if (isset($_POST['save_excerpt']) && $_POST['save_excerpt']) {
            $saveExcerpt = '1';
        } else {
            $saveExcerpt = '0';
        }
        update_option('motopress-ce-save-excerpt', $saveExcerpt);
        // Hide options
        if (is_multisite() && is_main_site() && is_super_admin()) {
            if (isset($_POST['hide_options']) && $_POST['hide_options']) {
                $hideOptions = '1';
            } else {
                $hideOptions = '0';
            }
            update_site_option('motopress-ce-hide-options-on-subsites', $hideOptions);
        }
        //Google Fonts Classes
        if (isset($_POST['google_font_dir_writable'])) {
            $fontClasses = isset($_POST['motopress_google_font_classes']['opensans']) ? array('opensans' => $_POST['motopress_google_font_classes']['opensans']) : array();
            saveGoogleFontClasses($fontClasses);
        }
        wp_redirect(get_admin_url() . 'admin.php?page=' . $_GET['page'] . '&settings-updated=true');
    }
}
Ejemplo n.º 3
0
function motopressCESettingsSave()
{
    global $motopressCESettings;
    $pluginId = isset($_GET['plugin']) ? $_GET['plugin'] : $motopressCESettings['plugin_short_name'];
    if ($pluginId === $motopressCESettings['plugin_short_name']) {
        if (!empty($_POST)) {
            global $motopressCESettings;
            // Language
            if (isset($_POST['language']) && !empty($_POST['language'])) {
                $language = $_POST['language'];
                update_option('motopress-language', $language);
                $motopressCESettings['lang'] = motopressCEGetLang();
            }
            // Post Types
            $postTypes = array();
            if (isset($_POST['post_types']) and count($_POST['post_types']) > 0) {
                $postTypes = $_POST['post_types'];
            }
            update_option('motopress-ce-options', $postTypes);
            // Roles
            $disabledRoles = array();
            if (isset($_POST['disabled_roles']) and count($_POST['disabled_roles']) > 0) {
                $disabledRoles = $_POST['disabled_roles'];
            }
            update_option('motopress-ce-disabled-roles', $disabledRoles);
            // AutoSave
            if (isset($_POST['autosave_autodraft'])) {
                $autosave = '1';
            } else {
                $autosave = '0';
            }
            update_option('motopress-ce-autosave-autodraft', $autosave);
            // Spellcheck
            if (isset($_POST['spellcheck_enable'])) {
                $spellcheck_enable = '1';
            } else {
                $spellcheck_enable = '0';
            }
            update_option('motopress-ce-spellcheck-enable', $spellcheck_enable);
            // Custom CSS
            if (isset($_POST['custom_css'])) {
                if (!file_exists($motopressCESettings['motopress_upload_dir'])) {
                    mkdir($motopressCESettings['motopress_upload_dir'], 0777);
                }
                $current_css = $_POST['custom_css'];
                // css file creation & rewrite
                if (!empty($current_css)) {
                    $content = stripslashes($current_css);
                    clearstatcache();
                    if (is_writable($motopressCESettings['wp_upload_dir'])) {
                        file_put_contents($motopressCESettings['custom_css_file_path'], $content);
                    }
                } else {
                    if (file_exists($motopressCESettings['custom_css_file_path'])) {
                        clearstatcache();
                        if (is_writable($motopressCESettings['wp_upload_dir'])) {
                            unlink($motopressCESettings['custom_css_file_path']);
                        }
                    }
                }
                // css file deletion END
            }
            // Excerpt shortcode
            if (isset($_POST['excerpt_shortcode']) && $_POST['excerpt_shortcode']) {
                $excerptShortcode = '1';
            } else {
                $excerptShortcode = '0';
            }
            update_option('motopress-ce-excerpt-shortcode', $excerptShortcode);
            // Save excerpt
            if (isset($_POST['save_excerpt']) && $_POST['save_excerpt']) {
                $saveExcerpt = '1';
            } else {
                $saveExcerpt = '0';
            }
            update_option('motopress-ce-save-excerpt', $saveExcerpt);
            // Hide options
            if (is_multisite() && is_main_site() && is_super_admin()) {
                if (isset($_POST['hide_options']) && $_POST['hide_options']) {
                    $hideOptions = '1';
                } else {
                    $hideOptions = '0';
                }
                update_site_option('motopress-ce-hide-options-on-subsites', $hideOptions);
            }
            //Google Fonts Classes
            if (isset($_POST['google_font_dir_writable'])) {
                $fontClasses = isset($_POST['motopress_google_font_classes']) ? $_POST['motopress_google_font_classes'] : array();
                saveGoogleFontClasses($fontClasses);
            }
            wp_redirect(add_query_arg(array('page' => $_GET['page'], 'plugin' => $_GET['plugin'], 'settings-updated' => 'true'), admin_url('admin.php')));
        }
    } else {
        do_action('admin_mpce_settings_save-' . $pluginId);
    }
}