Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * TwentyTen functions and definitions
- *
- * Sets up the theme and provides some helper functions. Some helper functions
- * are used in the theme as custom template tags. Others are attached to action and
- * filter hooks in WordPress to change core functionality.
- *
- * The first function, twentyten_setup(), sets up the theme by registering support
- * for various features in WordPress, such as post thumbnails, navigation menus, and the like.
- *
- * When using a child theme (see http://codex.wordpress.org/Theme_Development and
- * http://codex.wordpress.org/Child_Themes), you can override certain functions
- * (those wrapped in a function_exists() call) by defining them first in your child theme's
- * functions.php file. The child theme's functions.php file is included before the parent
- * theme's file, so the child theme functions would be used.
- *
- * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
- * to a filter or action hook. The hook can be removed by using remove_action() or
- * remove_filter() and you can attach your own function to the hook.
- *
- * We can remove the parent theme's hook only after it is attached, which means we need to
- * wait until setting up the child theme:
- *
- * <code>
- * add_action( 'after_setup_theme', 'my_child_theme_setup' );
- * function my_child_theme_setup() {
- * // We are providing our own filter for excerpt_length (or using the unfiltered value)
- * remove_filter( 'excerpt_length', 'twentyten_excerpt_length' );
- * ...
- * }
- * </code>
- *
- * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
- *
- * @package WordPress
- * @subpackage Twenty_Ten
- * @since Twenty Ten 1.0
- */
- /*
- * Set the content width based on the theme's design and stylesheet.
- *
- * Used to set the width of images and content. Should be equal to the width the theme
- * is designed for, generally via the style.css stylesheet.
- */
- if ( ! isset( $content_width ) )
- $content_width = 640;
- /* Tell WordPress to run twentyten_setup() when the 'after_setup_theme' hook is run. */
- add_action( 'after_setup_theme', 'twentyten_setup' );
- if ( ! function_exists( 'twentyten_setup' ) ):
- /**
- * Set up theme defaults and registers support for various WordPress features.
- *
- * Note that this function is hooked into the after_setup_theme hook, which runs
- * before the init hook. The init hook is too late for some features, such as indicating
- * support post thumbnails.
- *
- * To override twentyten_setup() in a child theme, add your own twentyten_setup to your child theme's
- * functions.php file.
- *
- * @uses add_theme_support() To add support for post thumbnails, custom headers and backgrounds, and automatic feed links.
- * @uses register_nav_menus() To add support for navigation menus.
- * @uses add_editor_style() To style the visual editor.
- * @uses load_theme_textdomain() For translation/localization support.
- * @uses register_default_headers() To register the default custom header images provided with the theme.
- * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
- *
- * @since Twenty Ten 1.0
- */
- function twentyten_setup() {
- // This theme styles the visual editor with editor-style.css to match the theme style.
- add_editor_style();
- // Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories.
- add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
- // This theme uses post thumbnails
- add_theme_support( 'post-thumbnails' );
- // Add default posts and comments RSS feed links to head
- add_theme_support( 'automatic-feed-links' );
- /*
- * Make theme available for translation.
- * Translations can be filed in the /languages/ directory
- */
- load_theme_textdomain( 'twentyten', get_template_directory() . '/languages' );
- // This theme uses wp_nav_menu() in one location.
- register_nav_menus( array(
- 'user-login-menu' => __( 'User Login Navigation', 'twentyten' ),
- 'header-menu' => __( 'Header Navigation', 'twentyten' ),
- 'footer-menu' => __( 'Footer Navigation', 'twentyten' ),
- 'responsive-menu' => __( 'Responsive Navigation', 'twentyten' ),
- 'wob-footer-menu' => __( 'WOB Footer Navigation', 'twentyten' ),
- 'not-found-menu' => __( 'Page not found Navigation', 'twentyten' ),
- ) );
- }
- endif;
- if ( ! function_exists( 'twentyten_admin_header_style' ) ) :
- /**
- * Style the header image displayed on the Appearance > Header admin panel.
- *
- * Referenced via add_custom_image_header() in twentyten_setup().
- *
- * @since Twenty Ten 1.0
- */
- function twentyten_admin_header_style() {
- ?>
- <style type="text/css" id="twentyten-admin-header-css">
- /* Shows the same border as on front end */
- #headimg {
- border-bottom: 1px solid #000;
- border-top: 4px solid #000;
- }
- /* If header-text was supported, you would style the text with these selectors:
- #headimg #name { }
- #headimg #desc { }
- */
- </style>
- <?php
- }
- endif;
- /**
- * Show a home link for our wp_nav_menu() fallback, wp_page_menu().
- *
- * To override this in a child theme, remove the filter and optionally add
- * your own function tied to the wp_page_menu_args filter hook.
- *
- * @since Twenty Ten 1.0
- *
- * @param array $args An optional array of arguments. @see wp_page_menu()
- */
- function twentyten_page_menu_args( $args ) {
- if ( ! isset( $args['show_home'] ) )
- $args['show_home'] = true;
- return $args;
- }
- add_filter( 'wp_page_menu_args', 'twentyten_page_menu_args' );
- /**
- * Set the post excerpt length to 40 characters.
- *
- * To override this length in a child theme, remove the filter and add your own
- * function tied to the excerpt_length filter hook.
- *
- * @since Twenty Ten 1.0
- *
- * @param int $length The number of excerpt characters.
- * @return int The filtered number of excerpt characters.
- */
- function twentyten_excerpt_length( $length ) {
- return 12;
- }
- add_filter( 'excerpt_length', 'twentyten_excerpt_length' );
- if ( ! function_exists( 'twentyten_continue_reading_link' ) ) :
- /**
- * Return a "Continue Reading" link for excerpts.
- *
- * @since Twenty Ten 1.0
- *
- * @return string "Continue Reading" link.
- */
- function twentyten_continue_reading_link()
- {
- return '<div class="readMore"><a href="'. get_permalink() . '" class="more">' . __( 'More', 'twentyten' ) . '</a></div>';
- }
- endif;
- /**
- * Replace "[...]" with an ellipsis and twentyten_continue_reading_link().
- *
- * "[...]" is appended to automatically generated excerpts.
- *
- * To override this in a child theme, remove the filter and add your own
- * function tied to the excerpt_more filter hook.
- *
- * @since Twenty Ten 1.0
- *
- * @param string $more The Read More text.
- * @return string An ellipsis.
- */
- function twentyten_auto_excerpt_more( $more )
- {
- if ( ! is_admin() ) {
- return ' …' . twentyten_continue_reading_link();
- }
- return $more;
- }
- add_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' );
- /**
- * Add a pretty "Continue Reading" link to custom post excerpts.
- *
- * To override this link in a child theme, remove the filter and add your own
- * function tied to the get_the_excerpt filter hook.
- *
- * @since Twenty Ten 1.0
- *
- * @param string $output The "Coninue Reading" link.
- * @return string Excerpt with a pretty "Continue Reading" link.
- */
- function twentyten_custom_excerpt_more( $output ) {
- if ( has_excerpt() && ! is_attachment() && ! is_admin() ) {
- $output .= twentyten_continue_reading_link();
- }
- return $output;
- }
- add_filter( 'get_the_excerpt', 'twentyten_custom_excerpt_more' );
- /**
- * Remove inline styles printed when the gallery shortcode is used.
- *
- * Galleries are styled by the theme in Twenty Ten's style.css. This is just
- * a simple filter call that tells WordPress to not use the default styles.
- *
- * @since Twenty Ten 1.2
- */
- add_filter( 'use_default_gallery_style', '__return_false' );
- /**
- * Deprecated way to remove inline styles printed when the gallery shortcode is used.
- *
- * This function is no longer needed or used. Use the use_default_gallery_style
- * filter instead, as seen above.
- *
- * @since Twenty Ten 1.0
- * @deprecated Deprecated in Twenty Ten 1.2 for WordPress 3.1
- *
- * @return string The gallery style filter, with the styles themselves removed.
- */
- function twentyten_remove_gallery_css( $css ) {
- return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
- }
- // Backwards compatibility with WordPress 3.0.
- if ( version_compare( $GLOBALS['wp_version'], '3.1', '<' ) )
- add_filter( 'gallery_style', 'twentyten_remove_gallery_css' );
- if ( ! function_exists( 'twentyten_comment' ) ) :
- /**
- * Template for comments and pingbacks.
- *
- * To override this walker in a child theme without modifying the comments template
- * simply create your own twentyten_comment(), and that function will be used instead.
- *
- * Used as a callback by wp_list_comments() for displaying the comments.
- *
- * @since Twenty Ten 1.0
- *
- * @param object $comment The comment object.
- * @param array $args An array of arguments. @see get_comment_reply_link()
- * @param int $depth The depth of the comment.
- */
- function twentyten_comment( $comment, $args, $depth ) {
- $GLOBALS['comment'] = $comment;
- switch ( $comment->comment_type ) :
- case '' :
- ?>
- <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
- <div id="comment-<?php comment_ID(); ?>">
- <div class="comment_img_title">
- <div class="comment-author vcard">
- <div class="cmmentImg">
- <?php echo get_avatar( $comment, 55 ); ?>
- </div>
- <?php echo '<h5>'.get_comment_author_link().'</h5>' ?>
- </div>
- </div>
- <div class="comment_box">
- <?php if ( $comment->comment_approved == '0' ) : ?>
- <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentyten' ); ?></em>
- <br />
- <?php endif; ?>
- <div class="comment-meta commentmetadata">
- <div class="date">
- <a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
- <?php
- /* translators: 1: date, 2: time */
- printf( __( '%1$s', 'twentyten' ), get_comment_date()); ?>
- </a>
- </div>
- </div><!-- .comment-meta .commentmetadata -->
- <div class="comment-body"><?php comment_text(); ?></div>
- <div class="reply">
- <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ,'reply_text'=>'reply this comment' ) ) ); ?>
- </div><!-- .reply -->
- </div>
- </div><!-- #comment-## -->
- <?php
- break;
- case 'pingback' :
- case 'trackback' :
- ?>
- <li class="post pingback">
- <p><?php _e( 'Pingback:', 'twentyten' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' ); ?></p>
- <?php
- break;
- endswitch;
- }
- endif;
- /**
- * Register widgetized areas, including two sidebars and four widget-ready columns in the footer.
- *
- * To override twentyten_widgets_init() in a child theme, remove the action hook and add your own
- * function tied to the init hook.
- *
- * @since Twenty Ten 1.0
- *
- * @uses register_sidebar()
- */
- function twentyten_widgets_init() {
- // Area 1, located at the top of the sidebar.
- register_sidebar( array(
- 'name' => __( 'Primary Widget Area', 'twentyten' ),
- 'id' => 'primary-widget-area',
- 'description' => __( 'Add widgets here to appear in your sidebar.', 'twentyten' ),
- 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
- 'after_widget' => '</li>',
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3>',
- ) );
- // Area 2, located below the Primary Widget Area in the sidebar. Empty by default.
- register_sidebar( array(
- 'name' => __( 'Secondary Widget Area', 'twentyten' ),
- 'id' => 'secondary-widget-area',
- 'description' => __( 'An optional secondary widget area, displays below the primary widget area in your sidebar.', 'twentyten' ),
- 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
- 'after_widget' => '</li>',
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3>',
- ) );
- // Area 3, located in the footer. Empty by default.
- register_sidebar( array(
- 'name' => __( 'Third Footer Widget Area', 'twentyten' ),
- 'id' => 'third-footer-widget-area',
- 'description' => __( 'An optional widget area for your site footer.', 'twentyten' ),
- 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
- 'after_widget' => '</li>',
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3>',
- ) );
- // Area 4, located in the footer. Empty by default.
- register_sidebar( array(
- 'name' => __( 'FAQ Widget Area', 'twentyten' ),
- 'id' => 'faq-widget-area',
- 'description' => __( 'An optional widget area for your site faq.', 'twentyten' ),
- 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
- 'after_widget' => '</li>',
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3>',
- ) );
- }
- /** Register sidebars by running twentyten_widgets_init() on the widgets_init hook. */
- add_action( 'widgets_init', 'twentyten_widgets_init' );
- /**
- * Remove the default styles that are packaged with the Recent Comments widget.
- *
- * To override this in a child theme, remove the filter and optionally add your own
- * function tied to the widgets_init action hook.
- *
- * This function uses a filter (show_recent_comments_widget_style) new in WordPress 3.1
- * to remove the default style. Using Twenty Ten 1.2 in WordPress 3.0 will show the styles,
- * but they won't have any effect on the widget in default Twenty Ten styling.
- *
- * @since Twenty Ten 1.0
- */
- function twentyten_remove_recent_comments_style() {
- add_filter( 'show_recent_comments_widget_style', '__return_false' );
- }
- add_action( 'widgets_init', 'twentyten_remove_recent_comments_style' );
- if ( ! function_exists( 'twentyten_posted_on' ) ) :
- /**
- * Print HTML with meta information for the current post-date/time and author.
- *
- * @since Twenty Ten 1.0
- */
- function twentyten_posted_on() {
- printf( __( '<span class="%1$s"><strong>By</strong></span> %3$s <span class="meta-sep"><strong>on</strong></span> %2$s', 'twentyten' ),
- 'meta-prep meta-prep-author',
- sprintf( '<span class="entry-date">%3$s</span>',
- get_permalink(),
- esc_attr( get_the_time() ),
- get_the_date('d M Y')
- ),
- sprintf( '<span class="author vcard"><span class="url fn n" href="%1$s" title="%2$s">%3$s</span></span>',
- get_author_posts_url( get_the_author_meta( 'ID' ) ),
- esc_attr( sprintf( __( 'View all posts by %s', 'twentyten' ), get_the_author() ) ),
- get_the_author()
- )
- );
- }
- endif;
- if ( ! function_exists( 'twentyten_posted_in' ) ) :
- /**
- * Print HTML with meta information for the current post (category, tags and permalink).
- *
- * @since Twenty Ten 1.0
- */
- function twentyten_posted_in() {
- // Retrieves tag list of current post, separated by commas.
- $tag_list = get_the_tag_list( '', ', ' );
- if ( $tag_list ) {
- $posted_in = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
- } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
- $posted_in = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
- } else {
- $posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
- }
- // Prints the string, replacing the placeholders.
- printf(
- $posted_in,
- get_the_category_list( ', ' ),
- $tag_list,
- get_permalink(),
- the_title_attribute( 'echo=0' )
- );
- }
- endif;
- /**
- * Retrieve the IDs for images in a gallery.
- *
- * @uses get_post_galleries() First, if available. Falls back to shortcode parsing,
- * then as last option uses a get_posts() call.
- *
- * @since Twenty Ten 1.6.
- *
- * @return array List of image IDs from the post gallery.
- */
- function twentyten_get_gallery_images() {
- $images = array();
- if ( function_exists( 'get_post_galleries' ) ) {
- $galleries = get_post_galleries( get_the_ID(), false );
- if ( isset( $galleries[0]['ids'] ) )
- $images = explode( ',', $galleries[0]['ids'] );
- } else {
- $pattern = get_shortcode_regex();
- preg_match( "/$pattern/s", get_the_content(), $match );
- $atts = shortcode_parse_atts( $match[3] );
- if ( isset( $atts['ids'] ) )
- $images = explode( ',', $atts['ids'] );
- }
- if ( ! $images ) {
- $images = get_posts( array(
- 'fields' => 'ids',
- 'numberposts' => 999,
- 'order' => 'ASC',
- 'orderby' => 'menu_order',
- 'post_mime_type' => 'image',
- 'post_parent' => get_the_ID(),
- 'post_type' => 'attachment',
- ) );
- }
- return $images;
- }
- add_action( 'after_setup_theme', 'woocommerce_support' );
- function woocommerce_support()
- {
- add_theme_support( 'woocommerce' );
- }
- if( ! class_exists( 'WP_List_Table' ) )
- {
- require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
- }
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
- add_action ('admin_print_scripts','life_backend_js');
- function life_backend_js()
- {
- wp_enqueue_script('jquery');
- wp_enqueue_script('editor');
- wp_enqueue_script('jquery-ui-datepicker');
- wp_enqueue_script('backend_js' ,get_template_directory_uri().'/js/life-style-backtend.js');
- wp_enqueue_script('thickbox');
- wp_enqueue_script('farbtastic');
- wp_enqueue_script('media-upload');
- wp_enqueue_script('wp-color-picker');
- wp_enqueue_script( 'my-script-handle', get_template_directory_uri() .'/inc/js/options-custom.js', array( 'wp-color-picker' ), false, true );
- }
- add_action ('admin_print_styles','life_backend_css');
- function life_backend_css()
- {
- wp_enqueue_style('thickbox');
- wp_enqueue_style('farbtastic');
- wp_enqueue_style('media-upload');
- wp_enqueue_style('admin_css' ,get_template_directory_uri().'/css/admin_css.css');
- wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
- wp_enqueue_style( 'wp-color-picker' );
- }
- add_action( 'wp_enqueue_scripts', 'life_frontend_scripts' );
- function life_frontend_scripts()
- {
- wp_enqueue_script('jquery');
- wp_enqueue_style('jquery-style','//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/themes/smoothness/jquery-ui.css');
- wp_enqueue_script('google-jquery-ui','//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js');
- wp_enqueue_script('flex_js',get_template_directory_uri().'/js/flexslider/jquery.flexslider-min.js');
- wp_enqueue_style('flex_css' ,get_template_directory_uri().'/css/flexslider.css');
- wp_enqueue_script('front-quicksand-js' ,get_template_directory_uri().'/js/jquery.quicksand.js');
- wp_enqueue_script('front-ease-js' ,get_template_directory_uri().'/js/filter/jquery.easing.1.3.js');
- wp_enqueue_script('front-ease-com-js' ,get_template_directory_uri().'/js/filter/jquery.easing.compatibility.js');
- wp_enqueue_script('spinner-js' ,get_template_directory_uri().'/js/jquery.spinner.js');
- wp_enqueue_script('fancybox-js' ,get_template_directory_uri().'/js/popup/jquery.fancybox.js');
- wp_enqueue_style('fancybox-css', get_template_directory_uri().'/css/popup/jquery.fancybox.css');
- wp_enqueue_script('validation-js' ,'//ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/jquery.validate.js');
- wp_enqueue_script('countdown-js' ,get_template_directory_uri().'/js/flip-clock/countdown.js');
- wp_enqueue_script('front-js' ,get_template_directory_uri().'/js/life-style-frontend.js');
- }
- add_action( 'wp_enqueue_scripts', 'life_footer_script' );
- function life_footer_script()
- {
- wp_enqueue_script('footer-script1-js' ,get_template_directory_uri().'/js/bootstrap.min.js');
- wp_enqueue_script('footer-script2-js' ,get_template_directory_uri().'/js/docs.min.js');
- }
- add_filter('widget_text', 'do_shortcode');
- if ( !function_exists( 'optionsframework_init' ) )
- {
- define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/inc/' );
- require_once dirname( __FILE__ ) . '/inc/options-framework.php';
- }
- require (get_template_directory().'/posttype-metabox.php');
- require (get_template_directory().'/shortcode.php');
- function BBL_change_password_form() {
- global $post;
- if (is_singular()) :
- $current_url = get_permalink($post->ID);
- else :
- $pageURL = 'http';
- if ($_SERVER["HTTPS"] == "on") $pageURL .= "s";
- $pageURL .= "://";
- if ($_SERVER["SERVER_PORT"] != "80") $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
- else $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
- $current_url = $pageURL;
- endif;
- $redirect = $current_url;
- ob_start();
- // show any error messages after form submission
- BBL_show_error_messages();
- ?>
- <?php if(isset($_GET['password-reset']) && $_GET['password-reset'] == 'true') { ?>
- <div class="BBL_message success">
- <span><?php _e('Password changed successfully', 'rcp'); ?></span>
- </div>
- <?php } ?>
- <form id="BBL_password_form" method="POST" action="<?php echo $current_url; ?>">
- <fieldset>
- <p>
- <label for="BBL_user_pass"><?php _e('New Password', 'rcp'); ?></label>
- <input name="BBL_user_pass" id="pippin_user_pass" class="required" type="password"/>
- </p>
- <p>
- <label for="BBL_user_pass_confirm"><?php _e('Password Confirm', 'rcp'); ?></label>
- <input name="BBL_user_pass_confirm" id="BBL_user_pass_confirm" class="required" type="password"/>
- </p>
- <p>
- <input type="hidden" name="BBL_action" value="reset-password"/>
- <input type="hidden" name="BBL_redirect" value="<?php echo $redirect; ?>"/>
- <input type="hidden" name="BBL_password_nonce" value="<?php echo wp_create_nonce('rcp-password-nonce'); ?>"/>
- <input id="BBL_password_submit" type="submit" class="yello_border_btn" value="<?php _e('Change Password', 'BBL'); ?>"/>
- </p>
- </fieldset>
- </form>
- <?php
- return ob_get_clean();
- }
- // password reset form
- function BBL_reset_password_form()
- {
- if(is_user_logged_in())
- {
- return BBL_change_password_form();
- }
- }
- add_shortcode('password_form', 'BBL_reset_password_form');
- function BBL_reset_password() {
- // reset a users password
- if(isset($_POST['BBL_action']) && $_POST['BBL_action'] == 'reset-password')
- {
- global $user_ID;
- if(!is_user_logged_in())
- return;
- if(wp_verify_nonce($_POST['BBL_password_nonce'], 'rcp-password-nonce'))
- {
- if($_POST['BBL_user_pass'] == '' || $_POST['BBL_user_pass_confirm'] == '') {
- // password(s) field empty
- BBL_errors()->add('password_empty', __('Please enter a password, and confirm it', 'pippin'));
- }
- if($_POST['BBL_user_pass'] != $_POST['BBL_user_pass_confirm']) {
- // passwords do not match
- BBL_errors()->add('password_mismatch', __('Passwords do not match', 'pippin'));
- }
- // retrieve all error messages, if any
- $errors = BBL_errors()->get_error_messages();
- if(empty($errors))
- {
- // change the password here
- $user_data = array(
- 'ID' => $user_ID,
- 'user_pass' => $_POST['BBL_user_pass']
- );
- wp_update_user($user_data);
- // send password change email here (if WP doesn't)
- wp_redirect(add_query_arg('password-reset', 'true', $_POST['BBL_redirect']));
- exit;
- }
- }
- }
- }
- add_action('init', 'BBL_reset_password');
- if(!function_exists('BBL_show_error_messages')) {
- // displays error messages from form submissions
- function BBL_show_error_messages()
- {
- if($codes = BBL_errors()->get_error_codes())
- {
- echo '<div class="BBL_message error">';
- // Loop error codes and display errors
- foreach($codes as $code)
- {
- $message = BBL_errors()->get_error_message($code);
- echo '<span class="BBL_error"><strong>' . __('Error', 'rcp') . '</strong>: ' . $message . '</span><br/>';
- }
- echo '</div>';
- }
- }
- }
- if(!function_exists('BBL_errors'))
- {
- // used for tracking error messages
- function BBL_errors()
- {
- static $wp_error; // Will hold global variable safely
- return isset($wp_error) ? $wp_error : ($wp_error = new WP_Error(null, null, null));
- }
- }
- /*add_action( 'init', 'setcookie_for_country' );
- function setcookie_for_country()
- {
- if(!isset($_COOKIES['country-code']))
- {
- $ip = $_SERVER['REMOTE_ADDR'];
- $json = @file_get_contents("http://ipinfo.io/{$ip}");
- $details = json_decode($json);
- $country_code = $details->country;
- setcookie( 'country-code', $country_code, time() + (3600*24*30), '/');
- }
- add_action( 'init', 'setcookie_for_country' );
- function setcookie_for_country()
- {
- $ip = $_SERVER['REMOTE_ADDR'];
- $xml = simplexml_load_file("http://www.geoplugin.net/xml.gp?ip=".$ip);
- $country_code = $xml->geoplugin_countryCode ;
- setcookie( 'country-code', $country_code, time() + (3600*24*30), '/');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement