Esempio n. 1
1
 /**
  * Installs the blog
  *
  * {@internal Missing Long Description}}
  *
  * @since 2.1.0
  *
  * @param string $blog_title Blog title.
  * @param string $user_name User's username.
  * @param string $user_email User's email.
  * @param bool $public Whether blog is public.
  * @param string $deprecated Optional. Not used.
  * @param string $user_password Optional. User's chosen password. Will default to a random password.
  * @param string $language Optional. Language chosen.
  * @return array Array keys 'url', 'user_id', 'password', 'password_message'.
  */
 function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '')
 {
     if (!empty($deprecated)) {
         _deprecated_argument(__FUNCTION__, '2.6');
     }
     wp_check_mysql_version();
     wp_cache_flush();
     make_db_current_silent();
     populate_options();
     populate_roles();
     update_option('blogname', $blog_title);
     update_option('admin_email', $user_email);
     update_option('blog_public', $public);
     if ($language) {
         update_option('WPLANG', $language);
     }
     $guessurl = wp_guess_url();
     update_option('siteurl', $guessurl);
     // If not a public blog, don't ping.
     if (!$public) {
         update_option('default_pingback_flag', 0);
     }
     /*
      * Create default user. If the user already exists, the user tables are
      * being shared among blogs. Just set the role in that case.
      */
     $user_id = username_exists($user_name);
     $user_password = trim($user_password);
     $email_password = false;
     if (!$user_id && empty($user_password)) {
         $user_password = wp_generate_password(12, false);
         $message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
         $user_id = wp_create_user($user_name, $user_password, $user_email);
         update_user_option($user_id, 'default_password_nag', true, true);
         $email_password = true;
     } else {
         if (!$user_id) {
             // Password has been provided
             $message = '<em>' . __('Your chosen password.') . '</em>';
             $user_id = wp_create_user($user_name, $user_password, $user_email);
         } else {
             $message = __('User already exists. Password inherited.');
         }
     }
     $user = new WP_User($user_id);
     $user->set_role('administrator');
     wp_install_defaults($user_id);
     flush_rewrite_rules();
     wp_new_blog_notification($blog_title, $guessurl, $user_id, $email_password ? $user_password : __('The password you chose during the install.'));
     wp_cache_flush();
     /**
      * Fires after a site is fully installed.
      *
      * @since 3.9.0
      *
      * @param WP_User $user The site owner.
      */
     do_action('wp_install', $user);
     return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
 }
 /**
  * Enqueue the CSS and JS needed to make the magic happen
  * @param $hook
  */
 public function enqueueTheGoods($hook)
 {
     add_thickbox();
     if ($hook == 'post.php') {
         wp_enqueue_media();
     } else {
         if ($hook == 'upload.php') {
             $mode = get_user_option('media_library_mode', get_current_user_id()) ? get_user_option('media_library_mode', get_current_user_id()) : 'grid';
             if (isset($_GET['mode']) && in_array($_GET['mode'], ['grid', 'list'])) {
                 $mode = $_GET['mode'];
                 update_user_option(get_current_user_id(), 'media_library_mode', $mode);
             }
             if ($mode == 'list') {
                 $version = get_bloginfo('version');
                 if (version_compare($version, '4.2.2') < 0) {
                     wp_dequeue_script('media');
                 }
                 wp_enqueue_media();
             }
         } else {
             wp_enqueue_style('media-views');
         }
     }
     wp_enqueue_style('wp-pointer');
     wp_enqueue_style('ilab-modal-css', ILAB_PUB_CSS_URL . '/ilab-modal.min.css');
     wp_enqueue_style('ilab-media-tools-css', ILAB_PUB_CSS_URL . '/ilab-media-tools.min.css');
     wp_enqueue_script('wp-pointer');
     wp_enqueue_script('ilab-modal-js', ILAB_PUB_JS_URL . '/ilab-modal.js', ['jquery'], false, true);
     wp_enqueue_script('ilab-media-tools-js', ILAB_PUB_JS_URL . '/ilab-media-tools.js', ['jquery'], false, true);
 }
Esempio n. 3
0
function wpu_check_for_action()
{
    global $user_ID, $wp_version;
    if (isset($_GET['wpu_action'])) {
        if ('activate' == $_GET['wpu_action']) {
            check_admin_referer('wp-united-switch-theme_' . $_GET['template']);
            if (isset($_GET['template'])) {
                update_usermeta($user_ID, 'WPU_MyTemplate', $_GET['template']);
            }
            if (isset($_GET['stylesheet'])) {
                update_usermeta($user_ID, 'WPU_MyStylesheet', $_GET['stylesheet']);
            }
            $wpuConnSettings = get_settings('wputd_connection');
            wp_redirect('admin.php?page=' . $wpuConnSettings['full_path_to_plugin'] . '&activated=true&wputab=themes');
            exit;
        } elseif ('update-blog-profile' == $_GET['wpu_action']) {
            check_admin_referer('update-blog-profile_' . $user_ID);
            $errors = edit_user($user_ID);
            //$errors behaves differently post-WP 2.1
            if ((double) $wp_version >= 2.1) {
                //WordPress >= 2.1
                if (is_wp_error($errors)) {
                    foreach ($errors->get_error_messages() as $message) {
                        echo "<li>{$message}</li>";
                    }
                }
            } else {
                //WP 2.0x
                if (is_array($errors)) {
                    if (count($errors) != 0) {
                        foreach ($errors as $id => $error) {
                            echo $error . '<br/>';
                        }
                        exit;
                    }
                }
            }
            if (!isset($_POST['rich_editing'])) {
                $_POST['rich_editing'] = 'false';
            }
            update_user_option($current_user->id, 'rich_editing', $_POST['rich_editing'], true);
            //
            //	UPDATE BLOG DETAILS
            //
            $blog_title = __('My Blog');
            $blog_tagline = __('My description will go here');
            if (isset($_POST['blog_title'])) {
                $blog_title = wp_specialchars(trim($_POST['blog_title']));
            }
            if (isset($_POST['blog_tagline'])) {
                $blog_tagline = wp_specialchars(trim($_POST['blog_tagline']));
            }
            update_usermeta($user_ID, 'blog_title', $blog_title);
            update_usermeta($user_ID, 'blog_tagline', $blog_tagline);
            $wpuConnSettings = get_settings('wputd_connection');
            wp_redirect('admin.php?page=' . $wpuConnSettings['full_path_to_plugin'] . '&updated=true&wputab=bset');
            exit;
        }
    }
}
Esempio n. 4
0
 public function __construct()
 {
     parent::__construct();
     if (isset($_REQUEST['shipping_module_id'])) {
         update_user_option(get_current_user_id(), 'wpsc_settings_selected_shipping_module', $_REQUEST['shipping_module_id']);
     }
 }
Esempio n. 5
0
 /**
  * Stores user's preference to hide the submit message via AJAX
  */
 function hide()
 {
     check_ajax_referer($this->parent->slug_ . '_hide_submit', '_ajax_nonce-' . $this->parent->slug . '-hide-submit');
     //note: option will be global
     update_user_option(get_current_user_ID(), 'infinite-scroll-hide-submit', true, true);
     die(1);
 }
 public function __construct()
 {
     parent::__construct();
     global $cb_post_id;
     $this->settings = clearbase_get_folder_settings();
     $this->is_parent_settings = $cb_post_id != clearbase_get_value('_folder_id', 0, $this->settings);
     $this->show_folders = clearbase_get_value($this->is_parent_settings ? 'allow_child_nesting' : 'allow_nesting', true, $this->settings);
     $this->show_add_folders = !$this->show_folders ? false : apply_filters("clearbase_allow_new_folders", true, $cb_post_id);
     $this->show_media = !clearbase_is_root() || clearbase_is_root() && clearbase_get_value('allow_root_media', true, $this->settings);
     $this->show_media = apply_filters('clearbase_show_media', $this->show_media, $cb_post_id);
     $this->show_add_media = !$this->show_media ? false : apply_filters("clearbase_allow_new_media", true, $cb_post_id);
     $this->is_trash = false;
     //TODO
     if (clearbase_is_root(false)) {
         //enforce Clearbase root rules
         $this->show_folders = $this->show_add_folders = true;
         $this->show_media = $this->show_add_media = false;
     }
     $modes = array('grid', 'list');
     if (isset($_GET['mode']) && in_array($_GET['mode'], $modes)) {
         $this->mode = clearbase_empty_default($_GET, 'mode', '');
         update_user_option(get_current_user_id(), 'clearbase_media_mode', $this->mode);
     } else {
         $this->mode = get_user_option('clearbase_media_mode', get_current_user_id());
         if (!in_array($this->mode, $modes)) {
             $this->mode = 'list';
         }
     }
     if ($this->show_media && 'list' == $this->mode) {
         require_once CLEARBASE_DIR . '/includes/class-cb-media-list-table.php';
         $this->media_table = new CB_Media_List_Table();
     }
 }
function registrar_usuario($parametros)
{
    $errors = new WP_Error();
    if ($parametros['email'] == NULL) {
        $errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.'));
        return $errors;
    }
    if (!es_email($parametros['email'])) {
        $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn&#8217;t correct.'));
        return $errors;
    }
    if (email_exists($parametros['email'])) {
        $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'));
        return $errors;
    }
    if ($parametros['nombre'] == NULL) {
        $errors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username.'));
        return $errors;
    }
    $user_pass = $parametros['clave'] == NULL ? wp_generate_password(12, false) : $parametros['clave'];
    $user_id = wp_create_user($parametros['email'], $user_pass, $parametros['email']);
    if (!$user_id) {
        $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email')));
        return $errors;
    }
    update_user_option($user_id, 'default_password_nag', true, true);
    //Set up the Password change nag.
    wp_new_user_notification($user_id, $user_pass);
    // Actualización de tabla clientes...
    return $user_id;
}
Esempio n. 8
0
 function setUserValue($name, $value, $userID = 0)
 {
     if (empty($userID)) {
         $userID = $GLOBALS['user_ID'];
     }
     update_user_option($userID, $this->userOptionName($name), $value);
 }
Esempio n. 9
0
 public function step()
 {
     $exported_subs = get_user_option(get_current_user_id(), 'nf_download_all_subs_ids');
     if (!is_array($exported_subs)) {
         $exported_subs = array();
     }
     $previous_name = get_user_option(get_current_user_id(), 'nf_download_all_subs_filename');
     if ($previous_name) {
         $this->args['filename'] = $previous_name;
     }
     $args = array('posts_per_page' => 250, 'paged' => $this->step, 'post_type' => 'nf_sub', 'meta_query' => array(array('key' => '_form_id', 'value' => $this->args['form_id'])));
     $subs_results = get_posts($args);
     if (is_array($subs_results) && !empty($subs_results)) {
         $upload_dir = wp_upload_dir();
         $file_path = trailingslashit($upload_dir['path']) . $this->args['filename'] . '.csv';
         $myfile = fopen($file_path, 'a') or die('Unable to open file!');
         $x = 0;
         $export = '';
         foreach ($subs_results as $sub) {
             $sub_export = Ninja_Forms()->sub($sub->ID)->export(true);
             if ($x > 0 || $this->step > 1) {
                 $sub_export = substr($sub_export, strpos($sub_export, "\n") + 1);
             }
             if (!in_array($sub->ID, $exported_subs)) {
                 $export .= $sub_export;
                 $exported_subs[] = $sub->ID;
             }
             $x++;
         }
         fwrite($myfile, $export);
         fclose($myfile);
     }
     update_user_option(get_current_user_id(), 'nf_download_all_subs_ids', $exported_subs);
 }
Esempio n. 10
0
function yoimg_crop_load_styles_and_scripts($hook)
{
    if (YOIMG_CROP_ENABLED) {
        if ($hook == 'post.php') {
            wp_enqueue_media();
        } else {
            if ($hook == 'upload.php') {
                // issue http://stackoverflow.com/questions/25884434/wordpress-wp-enqueue-media-causes-javascript-error-from-wp-admin-upload-phpmo
                $mode = get_user_option('media_library_mode', get_current_user_id()) ? get_user_option('media_library_mode', get_current_user_id()) : 'grid';
                $modes = array('grid', 'list');
                if (isset($_GET['mode']) && in_array($_GET['mode'], $modes)) {
                    $mode = $_GET['mode'];
                    update_user_option(get_current_user_id(), 'media_library_mode', $mode);
                }
                if ('list' === $mode) {
                    $version = get_bloginfo('version');
                    // issue https://wordpress.org/support/topic/findposts-is-not-defined
                    if (version_compare($version, '4.2.2') < 0) {
                        wp_dequeue_script('media');
                    }
                    wp_enqueue_media();
                }
            } else {
                wp_enqueue_style('media-views');
            }
        }
        wp_enqueue_style('wp-pointer');
        wp_enqueue_style('yoimg-cropping-css', YOIMG_CROP_URL . '/css/yoimg-cropping.css');
        wp_enqueue_style('yoimg-cropper-css', YOIMG_CROP_URL . '/js/cropper/cropper.min.css');
        wp_enqueue_script('wp-pointer');
        wp_enqueue_script('yoimg-cropper-js', YOIMG_CROP_URL . '/js/cropper/cropper.min.js', array('jquery'), false, true);
        wp_enqueue_script('yoimg-cropping-js', YOIMG_CROP_URL . '/js/yoimg-cropping.js', array('yoimg-cropper-js'), false, true);
    }
}
Esempio n. 11
0
 function wr_contactform_ajax_hidden_columns()
 {
     // Set custom error reporting level
     error_reporting(E_ALL ^ E_NOTICE);
     if (!empty($_POST)) {
         $form = !empty($_POST['form_id']) ? $_POST['form_id'] : '';
         $postColumns = !empty($_POST['columns']) ? $_POST['columns'] : '';
         if (!empty($form)) {
             if (!($user = wp_get_current_user())) {
                 wp_die(-1);
             }
             $columns = array();
             $getColumns = get_user_option('wr_cfsb_post_type_column', $user->ID);
             if (!empty($getColumns)) {
                 $columns = $getColumns;
                 $columns[$form] = $postColumns;
             } else {
                 $columns[$form] = $postColumns;
             }
             update_user_option($user->ID, 'wr_cfsb_post_type_column', $columns, true);
         }
     } else {
         if (!empty($_GET)) {
             $form = !empty($_GET['form_id']) ? $_GET['form_id'] : '';
             if (!($user = wp_get_current_user())) {
                 wp_die(-1);
             }
             $columns = get_user_option('wr_cfsb_post_type_column', $user->ID);
             $data = !empty($columns[$form]) ? json_encode($columns[$form]) : '';
             echo '' . $data;
         }
     }
     exit;
 }
 function wp_new_user_notification($user_id, $plaintext_pass = '')
 {
     global $pagenow;
     global $register_plus_redux;
     //trigger_error( sprintf( __( 'Register Plus Redux DEBUG: wp_new_user_notification($user_id=%s, $plaintext_pass=%s) from %s', 'register-plus-redux' ), $user_id, $plaintext_pass, $pagenow ) );
     if ('1' === $register_plus_redux->rpr_get_option('user_set_password') && !empty($_POST['pass1'])) {
         $plaintext_pass = stripslashes((string) $_POST['pass1']);
     }
     if ('user-new.php' === $pagenow && !empty($_POST['pass1'])) {
         $plaintext_pass = stripslashes((string) $_POST['pass1']);
     }
     if ('1' === $register_plus_redux->rpr_get_option('user_set_password')) {
         update_user_option($user_id, 'default_password_nag', false, true);
     }
     // turn off the Password change nag.
     do_action('rpr_new_user', $user_id, $plaintext_pass);
     //TODO: Code now only forces users registering to verify email, may want to add settings to have admin created users verify email too
     $verification_code = '';
     $user_registering = 'wp-login.php' === $pagenow || $register_plus_redux->rpr_wp_modal_registration();
     if ($user_registering && '1' === $register_plus_redux->rpr_get_option('verify_user_email')) {
         $verification_code = wp_generate_password(20, FALSE);
         update_user_meta($user_id, 'email_verification_code', $verification_code);
         update_user_meta($user_id, 'email_verification_sent', gmdate('Y-m-d H:i:s'));
         $register_plus_redux->send_verification_mail($user_id, $verification_code);
     }
     if ($user_registering && '1' !== $register_plus_redux->rpr_get_option('disable_user_message_registered') || !$user_registering && '1' !== $register_plus_redux->rpr_get_option('disable_user_message_created')) {
         if ('1' !== $register_plus_redux->rpr_get_option('verify_user_email') && '1' !== $register_plus_redux->rpr_get_option('verify_user_admin')) {
             $register_plus_redux->send_welcome_user_mail($user_id, $plaintext_pass);
         }
     }
     if ($user_registering && '1' !== $register_plus_redux->rpr_get_option('disable_admin_message_registered') || !$user_registering && '1' !== $register_plus_redux->rpr_get_option('disable_admin_message_created')) {
         $register_plus_redux->send_admin_mail($user_id, $plaintext_pass, $verification_code);
     }
 }
 public function process_registration()
 {
     do_action('popmake_alm_ajax_override_registration');
     $user_login = $_POST['user_login'];
     $user_email = $_POST['user_email'];
     $user_pass = isset($_POST['user_pass']) ? $_POST['user_pass'] : wp_generate_password(12, false);
     $userdata = compact('user_login', 'user_email', 'user_pass');
     $user = wp_insert_user($userdata);
     if (!isset($_POST['user_pass'])) {
         update_user_option($user, 'default_password_nag', true, true);
         // Set up the Password change nag.
         wp_new_user_notification($user, $user_pass);
     }
     if (is_wp_error($user)) {
         $response = array('success' => false, 'message' => $user->get_error_message());
     } else {
         if (popmake_get_popup_ajax_registration($_POST['popup_id'], 'enable_autologin')) {
             $creds = array('user_login' => $user_login, 'user_password' => $user_pass, 'remember' => true);
             $user = wp_signon($creds);
         }
         $message = __('Registration complete.', 'popup-maker-ajax-login-modals');
         if (!isset($_POST['user_pass'])) {
             $message .= ' ' . __('Please check your e-mail.', 'popup-maker-ajax-login-modals');
         }
         $response = array('success' => true, 'message' => $message);
     }
     echo json_encode($response);
     die;
 }
 public function run($arguments)
 {
     global $itsec_globals;
     if (!isset($arguments['id'])) {
         return false;
         //User not provided
     }
     $user = get_user_by('id', intval($arguments['id']));
     if ($user === false) {
         return false;
         //user doesn't exist
     }
     $direction = isset($arguments['direction']) ? $arguments['direction'] : 'add';
     $enabled = trim(get_user_option('itsec_two_factor_enabled', $user->ID));
     $override = intval(get_user_option('itsec_two_factor_override', $user->ID)) === 1 ? true : false;
     $override_expires = intval(get_user_option('itsec_two_factor_override_expires', $user->ID));
     if ($direction === 'add') {
         if ($enabled != 'on' || $override !== 1 && $itsec_globals['current_time'] < $override_expires) {
             return false;
             //Override already active
         }
         $override = true;
         $override_expires = $itsec_globals['current_time'] + 600;
         $response = array('ID' => $user->ID, 'user_login' => $user->user_login, 'override' => $override, 'override_expires' => $override_expires);
         update_user_option($user->ID, 'itsec_two_factor_override', $override, true);
         update_user_option($user->ID, 'itsec_two_factor_override_expires', $override_expires, true);
         return $response;
     } elseif ($direction === 'remove') {
         delete_user_option($user->ID, 'itsec_two_factor_override', true);
         delete_user_option($user->ID, 'itsec_two_factor_override_expires', true);
         return true;
     }
     return false;
 }
 /**
  * Display the dashboard widget controls content.
  */
 public static function dashboard_widget_controls()
 {
     $number_of_days = self::get_number_of_days();
     $current_filter = self::get_current_filter();
     $available_filters = activity_heat_map_get_filters();
     if (isset($_REQUEST['activity_heat_map_filter'])) {
         $current_filter = sanitize_text_field($_REQUEST['activity_heat_map_filter']);
         if (!array_key_exists($current_filter, $available_filters)) {
             $current_filter = 'posts';
         }
         update_user_option(get_current_user_id(), 'activity_heat_map_filter', $current_filter);
     }
     if (isset($_REQUEST['activity_heat_map_days'])) {
         $number_of_days = absint($_REQUEST['activity_heat_map_days']);
         $number_of_days = $number_of_days <= 366 ? $number_of_days : 366;
         update_user_option(get_current_user_id(), 'activity_heat_map_days', $number_of_days);
     }
     echo '<p>';
     printf('<label for="activity_heat_map_filter">%s</label>', esc_html__('Show activity: ', 'activity-heat-map'));
     echo '<select name="activity_heat_map_filter" id="activity_heat_map_filter">';
     foreach ($available_filters as $filter => $data) {
         printf('<option value="%s" %s>%s</option>', esc_attr($filter), selected($current_filter, $filter), esc_html($data['title']));
     }
     echo '</select>';
     echo '</p>';
     echo '<p>';
     printf('<label for="activity_heat_map_days">%s</label>', esc_html__('Number of days: ', 'activity-heat-map'));
     printf('<input type="number" min="7" max="366" name="activity_heat_map_days" id="activity_heat_map_days" value="%s" />', absint($number_of_days));
     echo '</p>';
 }
function bogo_update_user_option($user_id)
{
    global $wpdb;
    $meta_key = $wpdb->get_blog_prefix() . 'accessible_locale';
    if (!empty($_POST['setting_bogo_accessible_locales'])) {
        delete_user_meta($user_id, $meta_key);
        if (isset($_POST['bogo_accessible_locales'])) {
            $locales = (array) $_POST['bogo_accessible_locales'];
            $locales = bogo_filter_locales($locales);
            foreach ($locales as $locale) {
                add_user_meta($user_id, $meta_key, $locale);
            }
        }
        if (!metadata_exists('user', $user_id, $meta_key)) {
            add_user_meta($user_id, $meta_key, 'zxx');
            // zxx is a special code in ISO 639-2
        }
    }
    if (isset($_POST['bogo_own_locale'])) {
        $locale = trim($_POST['bogo_own_locale']);
        if (bogo_is_available_locale($locale)) {
            update_user_option($user_id, 'locale', $locale, true);
        }
    }
}
 function wp_edit()
 {
     global $post_type, $wp_query;
     if ($post_type != GALLERY_POST_TYPE_SLUG) {
         return;
     }
     if (!current_user_can('edit_others_pages') || !post_type_supports($post_type, 'page-attributes') && !is_post_type_hierarchical($post_type)) {
         // check permission
         return;
     }
     add_action('restrict_manage_posts', array($this, 'restrict_manage_posts'));
     // posts per page drop down UI
     if (isset($_GET['per_page']) && ($_GET['per_page'] == 99999 || $_GET['per_page'] % 10 == 0)) {
         update_user_option(get_current_user_id(), 'edit_' . $post_type . '_per_page', (int) $_GET['per_page']);
     }
     add_filter('views_' . get_current_screen()->id, array($this, 'sort_by_order_link'));
     // add view by menu order to views
     add_filter('contextual_help', array($this, 'contextual_help'));
     // add contextual help to hierarchical post screens
     #if ( $wp_query->query['orderby'] == 'menu_order title' ) {	// we can only sort if we're organized by menu order; WP 3.2 and 3.1 versions
     wp_enqueue_script('simple-page-ordering', THEMEURL . 'inc/gallery-ordering/simple-page-ordering.js', array('jquery-ui-sortable'), '0.9.7', true);
     $js_trans = array('RepositionTree' => __("Items can only be repositioned within their current branch in the page tree / hierarchy (next to pages with the same parent).\n\nIf you want to move this item into a different part of the page tree, use the Quick Edit feature to change the parent before continuing.", TD));
     #wp_localize_script( 'simple-page-ordering', 'simple_page_ordering_l10n', $js_trans );
     #}
 }
 /**
  * Function for checking authorization to add as
  * a primary filter to control user and password
  */
 function addAuthenticatorCheckCode($userobj, $username, $password)
 {
     // If option at the user level is off I go out from the procedure
     // without other controls on the verification code twice
     if (!isset($userobj->ID) or trim(get_user_option('sz_google_authenticator_enabled', $userobj->ID)) != '1') {
         return $userobj;
     }
     // Checking and setting variables and secret code entered
     // A profile is stored in the master and the other is passed by login
     if (empty($_POST['googleauthotp'])) {
         $authenticator = '';
     } else {
         $authenticator = trim($_POST['googleauthotp']);
     }
     $options = $this->getModuleOptions('SZGoogleModuleAuthenticator');
     $secrets = trim(get_user_option('sz_google_authenticator_secret', $userobj->ID));
     // Control code inserted into the login form
     // with those in the table of secret codes Emergency
     if ($options['authenticator_emergency_codes'] == '1') {
         $em = unserialize(trim(get_user_option('sz_google_authenticator_codes', $userobj->ID)));
         if (is_array($em) and isset($em[$authenticator]) and $em[$authenticator] == false) {
             $em[$authenticator] = time();
             update_user_option($userobj->ID, 'sz_google_authenticator_codes', serialize($em), true);
             return $userobj;
         }
     }
     // Control code inserted into the login form with
     // that calculated routine internal authenticator class
     if ($this->checkAuthenticatorCode($secrets, $authenticator, $options['authenticator_discrepancy']) === true) {
         return $userobj;
     } else {
         return new WP_Error('invalid_google_authenticator_password', SZGoogleCommon::getTranslate('<strong>ERROR</strong>: Authenticator code is incorrect.', 'sz-google'));
     }
 }
Esempio n. 19
0
 /**
  * Save the meta box data.
  */
 public function save_metabox($post_id)
 {
     /*
     Verify using the nonce that the data was submitted from our meta box on our site.
     If it wasn't, return the post ID and be on our way.
     */
     // If no nonce was provided or the nonce does not match
     if (!isset($_POST[CCFIC_KEY . '_nonce']) || !wp_verify_nonce($_POST[CCFIC_KEY . '_nonce'], CCFIC_ID)) {
         return $post_id;
     }
     // Make sure the user has valid permissions
     // If we're editing a page and the user isn't allowed to do that, return the post ID
     if ('page' == $_POST['post_type']) {
         if (!current_user_can('edit_page', $post_id)) {
             return $post_id;
         }
     } else {
         if (!current_user_can('edit_post', $post_id)) {
             return $post_id;
         }
     }
     // Now that we've validated nonce and permissions, let's save the caption data
     // Sanitize the caption
     $caption = array('caption_text' => $_POST[CCFIC_KEY . '_caption_text'], 'source_text' => $_POST[CCFIC_KEY . '_source_text'], 'source_url' => esc_url($_POST[CCFIC_KEY . '_source_url']), 'new_window' => !empty($_POST[CCFIC_KEY . '_new_window']) ? true : false);
     // Update the caption meta field
     update_post_meta($post_id, '_' . CCFIC_KEY, $caption);
     // Update the user default for the "new window" checkbox
     update_user_option(get_current_user_id(), CCFIC_KEY . '_new_window', $caption['new_window']);
 }
Esempio n. 20
0
 /**
  * Installs the blog
  *
  * {@internal Missing Long Description}}
  *
  * @since 2.1.0
  *
  * @param string $blog_title Blog title.
  * @param string $user_name User's username.
  * @param string $user_email User's email.
  * @param bool $public Whether blog is public.
  * @param null $deprecated Optional. Not used.
  * @param string $user_password Optional. User's chosen password. Will default to a random password.
  * @return array Array keys 'url', 'user_id', 'password', 'password_message'.
  */
 function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '')
 {
     if (!empty($deprecated)) {
         _deprecated_argument(__FUNCTION__, '2.6');
     }
     wp_check_mysql_version();
     wp_cache_flush();
     make_db_current_silent();
     if (!is_file(ABSPATH . 'wp-admin/install.sql')) {
         //[ysd]如果有install.sql不设置默认options数据
         populate_options();
     } else {
         validate_active_plugins();
         //[ysd] 禁用 不可用的插件
     }
     populate_roles();
     update_option('blogname', $blog_title);
     update_option('admin_email', $user_email);
     update_option('blog_public', $public);
     $guessurl = isset($_SERVER['HTTP_APPNAME']) ? 'http://' . substr($_SERVER['HTTP_APPNAME'], 5) . '.1kapp.com' : wp_guess_url();
     //[ysd] 固定了guessurl
     update_option('siteurl', $guessurl);
     update_option('home', $guessurl);
     get_option('siteurl');
     // If not a public blog, don't ping.
     if (!$public) {
         update_option('default_pingback_flag', 0);
     }
     // Create default user. If the user already exists, the user tables are
     // being shared among blogs. Just set the role in that case.
     $user_id = username_exists($user_name);
     $user_password = trim($user_password);
     $email_password = false;
     if (!$user_id && empty($user_password)) {
         $user_password = wp_generate_password(12, false);
         $message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
         $user_id = wp_create_user($user_name, $user_password, $user_email);
         update_user_option($user_id, 'default_password_nag', true, true);
         $email_password = true;
     } else {
         if (!$user_id) {
             // Password has been provided
             $message = '<em>' . __('Your chosen password.') . '</em>';
             $user_id = wp_create_user($user_name, $user_password, $user_email);
         } else {
             $message = __('User already exists. Password inherited.');
         }
     }
     $user = new WP_User($user_id);
     $user->set_role('administrator');
     if (!file_exists(ABSPATH . 'wp-admin/without_default')) {
         wp_install_defaults($user_id);
     }
     //[ysd],如果打包时设置了默认数据,才会设置默认数据
     flush_rewrite_rules();
     wp_new_blog_notification($blog_title, $guessurl, $user_id, $email_password ? $user_password : __('The password you chose during the install.'));
     wp_cache_flush();
     return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
 }
Esempio n. 21
0
/**
 *
 * This function sets the dashboard column to 1 instead of the default 2 columns.
 *
 * @since 1.1
 *
 */
function crmpress_one_column_default()
{
    global $user_ID, $pagenow;
    $options = get_user_option('screen_layout_dashboard', $user_ID);
    if ($pagenow == 'index.php' && $options != 1) {
        update_user_option($user_ID, 'screen_layout_dashboard', 1, true);
    }
}
Esempio n. 22
0
 /**
  * Set finish flag for user
  *
  * @since  3.0
  * @return void
  */
 public function finish_tour()
 {
     // Verify nonce
     //if (!check_admin_referer(WPCACore::PREFIX.$post_id, WPCACore::NONCE))
     //	return;
     echo json_encode(update_user_option(get_current_user_id(), WPCACore::PREFIX . self::KEY_TOUR, time()));
     die;
 }
Esempio n. 23
0
 public function __construct()
 {
     parent::__construct();
     if (isset($_REQUEST['shipping_module_id'])) {
         update_user_option(get_current_user_id(), 'wpsc_settings_selected_shipping_module', sanitize_text_field($_REQUEST['shipping_module_id']));
     }
     add_action('admin_notices', array($this, 'no_shipping_notice'));
 }
Esempio n. 24
0
 public function __construct()
 {
     if (isset($_REQUEST['payment_gateway_id'])) {
         update_user_option(get_current_user_id(), 'wpsc_settings_selected_payment_gateway', $_REQUEST['payment_gateway_id']);
     }
     $this->active_gateways = get_option('custom_gateway_options');
     $this->gateway_names = get_option('payment_gateway_names');
 }
 public static function setScreenOptionCallback($option, $value)
 {
     if (AddActionsAndFilters_DataModelConfig::PER_PAGE_OPTION == $option) {
         $userId = get_current_user_id();
         if ($userId != 0) {
             update_user_option($userId, $option, $value);
         }
     }
 }
Esempio n. 26
0
 /**
  * Sets the screen layout to one column on the snippets add/edit screen
  * and adds filter for change the default title text.
  *
  * @since 1.0.0
  */
 public function screen()
 {
     if (Cwwp_Init::is_snippet_add_edit_screen()) {
         if (1 !== get_user_option('screen_layout_' . Cwwp_Init_Posttype::$post_type->name, get_current_user_id())) {
             update_user_option(get_current_user_id(), 'screen_layout_' . Cwwp_Init_Posttype::$post_type->name, 1, true);
         }
         add_filter('enter_title_here', array($this, 'title'));
     }
 }
 public function Remove_password_nag_if_browserid_registration()
 {
     global $user_ID;
     $registered_with_browserid = get_user_meta($user_ID, 'browserid_registration', true);
     if ($registered_with_browserid === true) {
         delete_user_setting('default_password_nag', $user_ID);
         update_user_option($user_ID, 'default_password_nag', false, true);
     }
 }
 static function PluginsApiFilter($res, $action, $args)
 {
     global $user_ID;
     $res = wpfb_call('ExtensionLib', 'QueryAvailableExtensions');
     if ($user_ID && !empty($res->info['tag_time'])) {
         update_user_option($user_ID, 'wpfb_ext_tagtime', $res->info['tag_time']);
     }
     return $res;
 }
Esempio n. 29
0
 public static function handle_screen_options()
 {
     if (isset($_REQUEST['wp_screen_options'])) {
         if (isset($_REQUEST['wp_screen_options']['option']) && 'groups_per_page' == $_REQUEST['wp_screen_options']['option']) {
             global $current_user;
             update_user_option($current_user->ID, $_REQUEST['wp_screen_options']['option'], $_REQUEST['wp_screen_options']['value']);
         }
     }
 }
Esempio n. 30
0
 /**
  * PHP unit setup function
  *
  * @return void
  */
 function setUp()
 {
     parent::setUp();
     $this->plugin = $GLOBALS['mentionable'];
     // We need to change user to verify editing option as admin or editor
     $administrator_id = $this->factory->user->create(array('role' => 'administrator'));
     update_user_option($administrator_id, 'rich_editing', 'true');
     wp_set_current_user($administrator_id);
 }