function is_mycred_ready() { global $mycred; $mycred = new myCRED_Settings(); // By default we start with the main sites setup. If it is not a multisite installation // get_blog_option() will default to get_option() for us. if ($mycred->is_multisite) { $setup = get_blog_option(1, 'mycred_setup_completed', false); } else { $setup = get_option('mycred_setup_completed', false); } // If it is a multisite and the master template is not used, check if this site has // been installed if ($mycred->is_multisite && $GLOBALS['blog_id'] > 1 && !$mycred->use_master_template) { $setup = get_blog_option($GLOBALS['blog_id'], 'mycred_setup_completed'); } // Make sure that if we switch from central log to seperate logs, we install this // log if it does not exists. if ($mycred->is_multisite && $GLOBALS['blog_id'] > 1 && !$mycred->use_master_template) { mycred_install_log($mycred->core['format']['decimals'], $mycred->log_table); } // If setup is set, we are ready if ($setup !== false) { return true; } // If we have come this far we need to load the setup require_once myCRED_INCLUDES_DIR . 'mycred-install.php'; $setup = new myCRED_Setup(); return $setup->status(); }
/** * Process Setup Steps * @since 0.1 * @version 1.0 */ public function process_choices() { // Make sure that if we are re-loading the setup page we do not execute again $singular = get_option('mycred_temp_singular'); if ($singular == $this->step) { return; } $step = $this->step; $settings = $this->core; $ok = false; // Save step 1 formats. if ($step == 1) { $ok = true; } elseif ($step == 2) { $settings['cred_id'] = 'mycred_default'; // Decimals $settings['format']['decimals'] = (int) sanitize_text_field($_POST['myCRED-format-dec']); if (empty($settings['format']['decimals'])) { $settings['format']['decimals'] = 0; } // Separators $settings['format']['separators']['decimal'] = $_POST['myCRED-sep-dec']; $settings['format']['separators']['thousand'] = $_POST['myCRED-sep-tho']; // DB Format if ($settings['format']['decimals'] > 0) { $settings['format']['type'] = 'decimal'; } else { $settings['format']['type'] = 'bigint'; } // Install database if (!function_exists('mycred_install_log')) { require_once myCRED_INCLUDES_DIR . 'mycred-functions.php'; } mycred_install_log($settings['format']['decimals'], $this->log_table); // Name $settings['name']['singular'] = sanitize_text_field($_POST['myCRED-name-singular']); $settings['name']['plural'] = sanitize_text_field($_POST['myCRED-name-plural']); // Prefix & Suffix $settings['before'] = sanitize_text_field($_POST['myCRED-prefix']); $settings['after'] = sanitize_text_field($_POST['myCRED-suffix']); update_option('mycred_pref_core', $settings); $this->core = $settings; $ok = true; } elseif ($step == 3) { // Capabilities $settings['caps']['plugin'] = isset($_POST['myCRED-cap-plugin']) ? trim($_POST['myCRED-cap-plugin']) : 'manage_options'; $settings['caps']['creds'] = isset($_POST['myCRED-cap-creds']) ? trim($_POST['myCRED-cap-creds']) : 'export'; $settings['max'] = isset($_POST['myCRED-max']) ? trim($_POST['myCRED-max']) : 0; // Excludes $settings['exclude']['plugin_editors'] = isset($_POST['myCRED-exclude-plugin-editors']) ? true : false; $settings['exclude']['cred_editors'] = isset($_POST['myCRED-exclude-cred-editors']) ? true : false; $settings['exclude']['list'] = sanitize_text_field($_POST['myCRED-exclude-list']); if (isset($_POST['myCRED-delete-user'])) { $settings['delete_user'] = sanitize_text_field($_POST['myCRED-delete-user']); } else { $settings['delete_user'] = 0; } // Save mycred_update_option('mycred_pref_core', $settings); $this->core = $settings; $ok = true; } if ($ok) { update_option('mycred_temp_singular', $step); } }