示例#1
0
function appthemes_update_redirect()
{
    if (!current_user_can('manage_options') || defined('DOING_AJAX')) {
        return;
    }
    // numeric array, contains multiple sets of arguments
    // first item contains preferable set
    $args_sets = get_theme_support('app-versions');
    $redirect = false;
    foreach ($args_sets as $args) {
        if ($args['current_version'] == get_option($args['option_key'])) {
            continue;
        }
        if ($args['current_version'] == get_transient(APP_UPDATE_TRANSIENT . '_' . $args['option_key'])) {
            continue;
        }
        set_transient(APP_UPDATE_TRANSIENT . '_' . $args['option_key'], $args['current_version']);
        // set redirect only for the first available arg set
        if (!$redirect) {
            $redirect = $args['update_page'];
        }
    }
    // no any redirect in all arg sets
    if (!$redirect) {
        return;
    }
    // prevents infinite redirect
    if (scbUtil::get_current_url() == admin_url($redirect)) {
        return;
    }
    wp_redirect(admin_url($redirect));
    exit;
}
 function page_content()
 {
     if (isset($_GET['firstrun'])) {
         do_action('appthemes_first_run');
     }
     $active_tab = isset($_GET['tab']) ? $_GET['tab'] : '';
     if (!isset($this->tabs[$active_tab])) {
         $active_tab = key($this->tabs);
     }
     $current_url = scbUtil::get_current_url();
     echo '<h3 class="nav-tab-wrapper">';
     foreach ($this->tabs as $tab_id => $tab_title) {
         $class = 'nav-tab';
         if ($tab_id == $active_tab) {
             $class .= ' nav-tab-active';
         }
         $href = add_query_arg('tab', $tab_id, $current_url);
         echo ' ' . html('a', compact('class', 'href'), $tab_title);
     }
     echo '</h3>';
     echo '<form method="post" action="">';
     echo '<input type="hidden" name="action" value="' . $active_tab . '" />';
     wp_nonce_field($this->nonce);
     foreach ($this->tab_sections[$active_tab] as $section) {
         echo $this->render_section($section['title'], $section['fields']);
     }
     echo '<p class="submit"><input type="submit" class="button-primary" value="' . esc_attr__('Save Changes', APP_TD) . '" /></p>';
     echo '</form>';
 }
示例#3
0
/**
 * Checks if a user is logged in, if not redirect them to the login page.
 */
function appthemes_auth_redirect_login()
{
    if (!is_user_logged_in()) {
        nocache_headers();
        wp_redirect(wp_login_url(scbUtil::get_current_url()));
        exit;
    }
}
示例#4
0
 public function admin_tools()
 {
     global $wpdb;
     if (!empty($_POST['search_index']['delete_index'])) {
         foreach (APP_Search_Index::get_registered_post_types() as $post_type) {
             $wpdb->update($wpdb->posts, array('post_content_filtered' => ''), array('post_type' => $post_type));
         }
         update_option(APP_SEARCH_INDEX_OPTION, 0);
         wp_redirect(scbUtil::get_current_url());
         exit;
     }
 }
示例#5
0
 function page_content()
 {
     do_action('tabs_' . $this->pagehook . '_page_content', $this);
     if (isset($_GET['firstrun'])) {
         do_action('appthemes_first_run');
     }
     $active_tab = isset($_GET['tab']) ? $_GET['tab'] : '';
     $tabs = $this->tabs->get_all();
     if (!isset($tabs[$active_tab])) {
         $active_tab = key($tabs);
     }
     $current_url = scbUtil::get_current_url();
     echo '<h2 class="nav-tab-wrapper">';
     foreach ($tabs as $tab_id => $tab_title) {
         $class = 'nav-tab';
         if ($tab_id == $active_tab) {
             $class .= ' nav-tab-active';
         }
         $href = esc_url(add_query_arg('tab', $tab_id, $current_url));
         echo ' ' . html('a', compact('class', 'href'), $tab_title);
     }
     echo '</h2>';
     echo '<form method="post" action="">';
     echo '<input type="hidden" name="action" value="' . $active_tab . '" />';
     wp_nonce_field($this->nonce);
     foreach ($this->tab_sections[$active_tab] as $section_id => $section) {
         if (isset($section['title'])) {
             echo html('h3 class="title"', $section['title']);
         }
         if (isset($section['desc'])) {
             echo html('p', $section['desc']);
         }
         if (isset($section['renderer'])) {
             call_user_func($section['renderer'], $section, $section_id);
         } else {
             if (isset($section['options']) && is_a($section['options'], 'scbOptions')) {
                 $formdata = $section['options'];
             } else {
                 $formdata = $this->options;
             }
             $this->render_section($section['fields'], $formdata->get());
         }
     }
     echo '<p class="submit"><input type="submit" class="button-primary" value="' . esc_attr__('Save Changes', APP_TD) . '" /></p>';
     echo '</form>';
 }
 /**
  * Import a user.
  *
  * @param string $subscriber The subscriber's email address
  * @param object|\Prompt_Post Post subscribe object for current post.
  */
 protected function import($subscriber, $object)
 {
     $existing_user = get_user_by('email', $subscriber);
     if ($existing_user and $object->is_subscribed($existing_user->ID)) {
         $this->already_subscribed_count++;
         return;
     }
     if (!$existing_user) {
         $subscriber_id = Prompt_User_Handling::create_from_email($subscriber);
     } else {
         $subscriber_id = $existing_user->ID;
     }
     $subscribed = $object->subscribe($subscriber_id);
     $prompt_user = new Prompt_User($subscriber_id);
     $origin = new Prompt_Subscriber_Origin(array('source_label' => 'Subscribe 2 Comments Reloaded Import', 'source_url' => scbUtil::get_current_url()));
     $prompt_user->set_subscriber_origin($origin);
     $this->imported_count++;
 }
示例#7
0
function appthemes_require_login($args = array())
{
    if (is_user_logged_in()) {
        return;
    }
    $page_url = scbUtil::get_current_url();
    $args = wp_parse_args($args, array('login_text' => __('You must first login.', APP_TD), 'login_register_text' => __('You must first login or <a href="%s">register</a>.', APP_TD)));
    if (get_option('users_can_register')) {
        $register_url = appthemes_get_registration_url();
        $register_url = add_query_arg('redirect_to', $page_url, $register_url);
        $message = sprintf($args['login_register_text'], $register_url);
    } else {
        $message = $args['login_text'];
    }
    set_transient('login_notice', array('error', $message), 300);
    appthemes_auth_redirect_login();
    exit;
}
示例#8
0
 /**
  * Import a MailPoet subscriber.
  *
  * @since 1.0.0
  * @param array $subscriber
  */
 protected function import($subscriber)
 {
     $existing_user = get_user_by('email', $subscriber['email']);
     if ($existing_user and $this->target_list->is_subscribed($existing_user->ID)) {
         $this->already_subscribed_count++;
         return;
     }
     if (!$existing_user) {
         $subscriber_id = Prompt_User_Handling::create_from_email($subscriber['email']);
         wp_update_user(array('ID' => $subscriber_id, 'first_name' => $subscriber['firstname'], 'last_name' => $subscriber['lastname']));
     } else {
         $subscriber_id = $existing_user->ID;
     }
     $this->target_list->subscribe($subscriber_id);
     $prompt_user = new Prompt_User($subscriber_id);
     $origin = new Prompt_Subscriber_Origin(array('source_label' => 'Mailpoet Import', 'source_url' => scbUtil::get_current_url()));
     $prompt_user->set_subscriber_origin($origin);
     $this->imported_count++;
 }
示例#9
0
 protected function import($subscriber)
 {
     $existing_user = get_user_by('email', $subscriber['email_address']);
     $prompt_site = new Prompt_Site();
     if ($existing_user and $prompt_site->is_subscribed($existing_user->ID)) {
         $this->already_subscribed_count++;
         return;
     }
     if ($existing_user) {
         $subscriber_id = $existing_user->ID;
     } else {
         $subscriber_id = Prompt_User_Handling::create_from_email($subscriber['email_address']);
     }
     $prompt_site->subscribe($subscriber_id);
     $prompt_user = new Prompt_User($subscriber_id);
     $origin = new Prompt_Subscriber_Origin(array('source_label' => 'Jetpack Import', 'source_url' => scbUtil::get_current_url()));
     $prompt_user->set_subscriber_origin($origin);
     $this->imported_count++;
 }
示例#10
0
文件: load.php 项目: kalushta/darom
/**
 * Register frontend/backend scripts and styles for later enqueue.
 */
function _appthemes_register_scripts()
{
    require_once APP_FRAMEWORK_DIR . '/js/localization.php';
    wp_register_style('jquery-ui-style', APP_FRAMEWORK_URI . '/styles/jquery-ui/jquery-ui.min.css', false, '1.11.2');
    wp_register_script('colorbox', APP_FRAMEWORK_URI . '/js/colorbox/jquery.colorbox.min.js', array('jquery'), '1.6.1');
    wp_register_style('colorbox', APP_FRAMEWORK_URI . '/js/colorbox/colorbox.css', false, '1.6.1');
    wp_register_style('font-awesome', APP_FRAMEWORK_URI . '/styles/font-awesome.min.css', false, '4.2.0');
    wp_register_style('appthemes-icons', APP_FRAMEWORK_URI . '/styles/font-appthemes.css', false, '1.0.0');
    wp_register_script('validate', APP_FRAMEWORK_URI . '/js/validate/jquery.validate.min.js', array('jquery'), '1.13.0');
    wp_register_script('footable', APP_FRAMEWORK_URI . '/js/footable/jquery.footable.min.js', array('jquery'), '2.0.3');
    wp_register_script('footable-grid', APP_FRAMEWORK_URI . '/js/footable/jquery.footable.grid.min.js', array('footable'), '2.0.3');
    wp_register_script('footable-sort', APP_FRAMEWORK_URI . '/js/footable/jquery.footable.sort.min.js', array('footable'), '2.0.3');
    wp_register_script('footable-filter', APP_FRAMEWORK_URI . '/js/footable/jquery.footable.filter.min.js', array('footable'), '2.0.3');
    wp_register_script('footable-striping', APP_FRAMEWORK_URI . '/js/footable/jquery.footable.striping.min.js', array('footable'), '2.0.3');
    wp_register_script('footable-paginate', APP_FRAMEWORK_URI . '/js/footable/jquery.footable.paginate.min.js', array('footable'), '2.0.3');
    wp_register_script('footable-bookmarkable', APP_FRAMEWORK_URI . '/js/footable/jquery.footable.bookmarkable.min.js', array('footable'), '2.0.3');
    // Generic JS data.
    wp_localize_script('jquery', 'AppThemes', array('ajaxurl' => admin_url('admin-ajax.php'), 'current_url' => scbUtil::get_current_url()));
    _appthemes_localize_scripts();
}