Usprawnienia tłumaczeń, poprawne wykonanie plików zip pluginów, usunięcie niewykorzystywanego pluginu client-portal, aktualizacja profile-bulder

This commit is contained in:
PiotrParysek 2017-06-09 14:13:44 +02:00
parent db17150983
commit 32831edf25
304 changed files with 54129 additions and 54846 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

View File

@ -1,26 +0,0 @@
.cl-grid{
box-sizing: border-box;
width: auto;
display: grid;
grid-gap: 40px;
grid-template-columns: 60% 30%;
}
.pb-pitch h2{
font-size: 24px;
font-weight:normal;
}
.pb-pitch h3{
font-size: 20px;
font-weight: normal;
}
.pb-pitch p, .pb-pitch ul{
font-size: 14px;
}
.pb-pitch ul{
list-style-type: disc;
margin: 0 0 auto 20px;
}

View File

@ -1,555 +0,0 @@
<?php
/**
* Plugin Name: Client Portal
* Plugin URI: http://www.cozmoslabs.com/
* Description: Build a company site with a client portal where clients login and see a restricted-access, personalized page of content with links and downloads.
* Version: 1.0.4
* Author: Cozmoslabs, Madalin Ungureanu, Antohe Cristian
* Author URI: http://www.cozmoslabs.com
* License: GPL2
*/
/* Copyright 2015 Cozmoslabs (www.cozmoslabs.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Define plugin path
*/
define( 'CP_URL', plugin_dir_url( __FILE__ ) );
class CL_Client_Portal
{
private $slug;
private $defaults;
public $options;
function __construct()
{
$this->slug = 'cp-options';
$this->options = get_option( $this->slug );
$this->defaults = array(
'page-slug' => 'private-page',
'support-comments' => 'no',
'restricted-message' => __( 'You do not have permission to view this page.', 'client-portal' ),
'portal-log-in-message' => __( 'Please log in in order to access the client portal.', 'client-portal' ),
'default-page-content' => ''
);
/* register the post type */
add_action( 'init', array( $this, 'cp_create_post_type' ) );
/* action to create a private page when a user registers */
add_action( 'user_register', array( $this, 'cp_create_private_page' ) );
/* remove the page when a user is deleted */
add_action( 'deleted_user', array( $this, 'cp_delete_private_page' ), 10, 2 );
/* restrict the content of the page only to the user */
add_filter( 'the_content', array( $this, 'cp_restrict_content' ) );
/* add a link in the Users List Table in admin area to access the page */
add_filter( 'user_row_actions', array( $this, 'cp_add_link_to_private_page' ), 10, 2);
/* add bulk action to create private user pages */
add_filter( 'admin_footer-users.php', array( $this, 'cp_create_private_page_bulk_actions' ) );
add_action( 'admin_action_create_private_page', array( $this, 'cp_create_private_pages_in_bulk' ) );
/* create client portal extra information */
add_filter('the_content', array( $this, 'cp_add_private_page_info'));
/* create the shortcode for the main page */
add_shortcode( 'client-portal', array( $this, 'cp_shortcode' ) );
/* create the settings page */
add_action( 'admin_menu', array( $this, 'cp_add_settings_page' ) );
/* register the settings */
add_action( 'admin_init', array( $this, 'cp_register_settings' ) );
/* show notices on the admin settings page */
add_action( 'admin_notices', array( $this, 'cp_admin_notices' ) );
// Enqueue scripts on the admin side
add_action( 'admin_enqueue_scripts', array( $this, 'cp_enqueue_admin_scripts' ) );
/* flush the rewrite rules when settings saved in case page slug was changed */
add_action('init', array( $this, 'cp_flush_rules' ), 20 );
/* make sure we don't have post navigation on the private pages */
add_filter( "get_previous_post_where", array( $this, 'cp_exclude_from_post_navigation' ), 10, 5 );
add_filter( "get_next_post_where", array( $this, 'cp_exclude_from_post_navigation' ), 10, 5 );
}
/**
* Function that registers the post type
*/
function cp_create_post_type() {
$labels = array(
'name' => _x( 'Private Pages', 'post type general name', 'client-portal' ),
'singular_name' => _x( 'Private Page', 'post type singular name', 'client-portal' ),
'menu_name' => _x( 'Private Page', 'admin menu', 'client-portal' ),
'name_admin_bar' => _x( 'Private Page', 'add new on admin bar', 'client-portal' ),
'add_new' => _x( 'Add New', 'private Page', 'client-portal' ),
'add_new_item' => __( 'Add New Private Page', 'client-portal' ),
'new_item' => __( 'New Private Page', 'client-portal' ),
'edit_item' => __( 'Edit Private Page', 'client-portal' ),
'view_item' => __( 'View Private Page', 'client-portal' ),
'all_items' => __( 'All Private Pages', 'client-portal' ),
'search_items' => __( 'Search Private Pages', 'client-portal' ),
'parent_item_colon' => __( 'Parent Private Page:', 'client-portal' ),
'not_found' => __( 'No Private Pages found.', 'client-portal' ),
'not_found_in_trash' => __( 'No Private Pages found in Trash.', 'client-portal' )
);
$args = array(
'labels' => $labels,
'description' => __( 'Description.', 'client-portal' ),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => false,
'query_var' => true,
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => true,
'supports' => array( 'title', 'editor', 'thumbnail' ),
'exclude_from_search' => true
);
if( !empty( $this->options['page-slug'] ) ){
$args['rewrite'] = array( 'slug' => $this->options['page-slug'] );
}
else{
$args['rewrite'] = array( 'slug' => $this->defaults['page-slug'] );
}
if( !empty( $this->options['support-comments'] ) && $this->options['support-comments'] == 'yes' )
$args['supports'][] = 'comments';
register_post_type( 'private-page', $args );
}
/**
* Function that creates the private page for a user
* @param $user_id the id of the user for which to create the page
*/
function cp_create_private_page( $user_id ){
/* check to see if we already have a page for the user */
$users_private_pages = $this->cp_get_private_page_for_user( $user_id );
if( !empty( $users_private_pages ) )
return;
/* make sure get_userdata() is available at this point */
if(is_admin()) require_once( ABSPATH . 'wp-includes/pluggable.php' );
$user = get_userdata( $user_id );
$display_name = '';
if( $user ){
$display_name = ($user->display_name) ? ($user->display_name) : ($user->user_login);
}
if( !empty( $this->options['default-page-content'] ) )
$post_content = $this->options['default-page-content'];
else
$post_content = $this->defaults['default-page-content'];
$private_page = array(
'post_title' => $display_name,
'post_status' => 'publish',
'post_type' => 'private-page',
'post_author' => $user_id,
'post_content' => $post_content
);
// Insert the post into the database
wp_insert_post( $private_page );
}
/**
* Function that deletes the private page when the user is deleted
* @param $id the id of the user which page we are deleting
* @param $reassign
*/
function cp_delete_private_page( $id, $reassign ){
$private_page_id = $this->cp_get_private_page_for_user( $id );
if( !empty( $private_page_id ) ){
wp_delete_post( $private_page_id, true );
}
}
/**
* Function that restricts the content only to the author of the page
* @param $content the content of the page
* @return mixed
*/
function cp_restrict_content( $content ){
global $post;
if( $post->post_type == 'private-page' ){
if( !empty( $this->options['restricted-message'] ) )
$message = $this->options['restricted-message'];
else
$message = $this->defaults['restricted-message'];
if( is_user_logged_in() ){
if( ( get_current_user_id() == $post->post_author ) || current_user_can('delete_user') ){
return $content;
}
else return $message;
}
else return $message;
}
return $content;
}
/**
* Function that adds a link in the user listing in admin area to access the private page
* @param $actions The actions available on the user listing in admin area
* @param $user_object The user object
* @return mixed
*/
function cp_add_link_to_private_page( $actions, $user_object ){
$private_page_id = $this->cp_get_private_page_for_user( $user_object->ID );
if( !empty( $private_page_id ) ){
$actions['private_page_link'] = "<a class='cp_private_page' href='" . admin_url( "post.php?post=$private_page_id&action=edit") . "'>" . __( 'Private Page', 'client-portal' ) . "</a>";
}
return $actions;
}
/**
* Function that creates a private page extra information div
* @param $content the content of the private page
* @return mixed
*/
function cp_add_private_page_info( $content ){
global $post;
if ( is_singular('private-page') && is_user_logged_in() ){
// logout link
$logout_link = wp_loginout( home_url(), false);
// author display name. Fallback to username if no display name is set.
$author_id=$post->post_author;
$user = get_user_by('id', $author_id);
$display_name = '';
if( $user ){
$display_name = ($user->display_name) ? ($user->display_name) : ($user->user_login);
}
$extra_info = "<p class='cp-logout' style='border-top: 1px solid #ccc; border-bottom: 1px solid #ccc; padding: 0.5rem 0; text-align: right'> $logout_link - $display_name </p>";
return $extra_info . $content;
}
return $content;
}
/**
* Function that creates a shortcode which redirects the user to its private page
* @param $atts the shortcode attributes
*/
function cp_shortcode( $atts ){
if( !is_user_logged_in() ){
if( !empty( $this->options['portal-log-in-message'] ) )
$message = $this->options['portal-log-in-message'];
else
$message = $this->defaults['portal-log-in-message'];
return $message;
}
else{
$user_id = get_current_user_id();
$private_page_id = $this->cp_get_private_page_for_user( $user_id );
if( $private_page_id ) {
$private_page_link = get_permalink($private_page_id);
?>
<script>
window.location.replace("<?php echo $private_page_link ?>");
</script>
<?php
}
}
}
/**
* Function that creates the admin settings page under the Users menu
*/
function cp_add_settings_page(){
add_users_page( 'Client Portal Settings', 'Client Portal Settings', 'manage_options', 'client_portal_settings', array( $this, 'cp_settings_page_content' ) );
}
/**
* Function that outputs the content for the settings page
*/
function cp_settings_page_content(){
/* if the user pressed the generate button then generate pages for existing users */
if( !empty( $_GET[ 'cp_generate_for_all' ] ) && $_GET[ 'cp_generate_for_all' ] == true ){
$this->cp_create_private_pages_for_all_users();
}
?>
<div class="wrap">
<h2><?php _e( 'Client Portal Settings', 'client-portal'); ?></h2>
<?php settings_errors(); ?>
<div class="cl-grid">
<div class="cl-grid-item">
<form method="POST" action="options.php">
<?php settings_fields( $this->slug ); ?>
<table class="form-table">
<tbody>
<tr class="scp-form-field-wrapper">
<th scope="row"><label class="scp-form-field-label" for="page-slug"><?php echo __( 'Page Slug' , 'client-portal' ) ?></label></th>
<td>
<input type="text" class="regular-text" id="page-slug" name="cp-options[page-slug]" value="<?php echo ( isset( $this->options['page-slug'] ) ? esc_attr( $this->options['page-slug'] ) : 'private-page' ); ?>" />
<p class="description"><?php echo __( 'The slug of the pages.', 'client-portal' ); ?></p>
</td>
</tr>
<tr class="scp-form-field-wrapper">
<th scope="row"><?php echo __( 'Support Comments' , 'client-portal' ) ?></th>
<td>
<label><input type="radio" id="support-comments" name="cp-options[support-comments]" value="no" <?php if( ( isset( $this->options['support-comments'] ) && $this->options['support-comments'] == 'no' ) || !isset( $this->options['support-comments'] ) ) echo 'checked="checked"' ?> /><?php _e( 'No', 'client-portal' ) ?></label><br />
<label><input type="radio" id="support-comments" name="cp-options[support-comments]" value="yes" <?php if( isset( $this->options['support-comments'] ) && $this->options['support-comments'] == 'yes' ) echo 'checked="checked"' ?> /><?php _e( 'Yes', 'client-portal' ) ?></label>
<p class="description"><?php echo __( 'Add comment support to the private page', 'client-portal' ); ?></p>
</td>
</tr>
<tr class="scp-form-field-wrapper">
<th scope="row"><?php echo __( 'Generate pages' , 'client-portal' ) ?></th>
<td>
<a class="button" href="<?php echo add_query_arg( 'cp_generate_for_all', 'true', admin_url("/users.php?page=client_portal_settings") ) ?>"><?php _e( 'Generate pages for existing users' ); ?></a>
<p class="description"><?php echo __( 'Generate pages for already existing users.', 'client-portal' ); ?></p>
</td>
</tr>
<tr class="scp-form-field-wrapper">
<th scope="row"><label class="scp-form-field-label" for="restricted-message"><?php echo __( 'Restricted Message' , 'client-portal' ) ?></label></th>
<td>
<textarea name="cp-options[restricted-message]" id="restricted-message" class="large-text" rows="10"><?php echo ( isset( $this->options['restricted-message'] ) ? esc_textarea( $this->options['restricted-message'] ) : $this->defaults['restricted-message'] ); ?></textarea>
<p class="description"><?php echo __( 'The default message showed on pages that are restricted.', 'client-portal' ); ?></p>
</td>
</tr>
<tr class="scp-form-field-wrapper">
<th scope="row"><label class="scp-form-field-label" for="portal-log-in-message"><?php echo __( 'Portal Log In Message' , 'client-portal' ) ?></label></th>
<td>
<textarea name="cp-options[portal-log-in-message]" id="portal-log-in-message" class="large-text" rows="10"><?php echo ( isset( $this->options['portal-log-in-message'] ) ? esc_textarea( $this->options['portal-log-in-message'] ) : $this->defaults['portal-log-in-message'] ); ?></textarea>
<p class="description"><?php echo __( 'The default message showed on pages that are restricted.', 'client-portal' ); ?></p>
</td>
</tr>
<tr class="scp-form-field-wrapper">
<th scope="row"><label class="scp-form-field-label" for="default-page-content"><?php echo __( 'Default Page Content' , 'client-portal' ) ?></label></th>
<td>
<textarea name="cp-options[default-page-content]" id="default-page-content" class="large-text" rows="10"><?php echo ( isset( $this->options['default-page-content'] ) ? esc_textarea( $this->options['default-page-content'] ) : $this->defaults['default-page-content'] ); ?></textarea>
<p class="description"><?php echo __( 'The default content on the private page.', 'client-portal' ); ?></p>
</td>
</tr>
</tbody>
</table>
<?php submit_button( __( 'Save Settings', 'client_portal_settings' ) ); ?>
</form>
</div>
<div class="cl-grid-item pb-pitch">
<h2>Get the most out of Client Portal</h2>
<p>When building a place for your clients to access information, it can take a lot of time simply because there isn't enough flexibility
to build exactly what you need.</p>
<p>Wouldn't it be nice to be able to build the experience for your clients using simple modules that each does as few things as possible, but well?</p>
<p style="text-align: center;"><a href="https://wordpress.org/plugins/profile-builder/"><img src="<?php echo CP_URL; ?>assets/logo_landing_pb_2x_red.png" alt="Profile Builder Logo"/></a></p>
<p><strong>Client Portal</strong> was designed to work together with
<a href="https://wordpress.org/plugins/profile-builder/"><strong>Profile Builder</strong></a> so you can construct the client experience just as you need it.
</p>
<ul>
<li>add a login form with redirect <br/> <strong>[wppb-login redirect_url="http://www.yourdomain.com/page"]</strong></li>
<li>allow users to register <strong>[wppb-register]</strong></li>
<li>hide the WordPress admin bar for clients</li>
</ul>
</div>
</div>
</div>
<?php
}
/**
* Function that registers the settings for the settings page with the Settings API
*/
public function cp_register_settings() {
register_setting( $this->slug, $this->slug, array( 'sanitize_callback' => array( $this, 'cp_sanitize_options' ) ) );
}
/**
* Function that sanitizes the options of the plugin
* @param $options
* @return mixed
*/
function cp_sanitize_options( $options ){
if( !empty( $options ) ){
foreach( $options as $key => $value ){
if( $key == 'page-slug' || $key == 'support-comments' )
$options[$key] = sanitize_text_field( $value );
elseif( $key == 'restricted-message' || $key == 'portal-log-in-message' )
$options[$key] = wp_kses_post( $value );
}
}
return $options;
}
/**
* Function that creates the notice messages on the settings page
*/
function cp_admin_notices(){
if( !empty( $_GET['page'] ) && $_GET['page'] == 'client_portal_settings' ) {
if( !empty( $_GET['cp_generate_for_all'] ) && $_GET['cp_generate_for_all'] == true ) {
?>
<div class="notice notice-success is-dismissible">
<p><?php _e( 'Successfully generated private pages for existing users.', 'client-portal'); ?></p>
</div>
<?php
if( !empty( $_REQUEST['settings-updated'] ) && $_GET['settings-updated'] == 'true' ) {
?>
<div class="notice notice-success is-dismissible">
<p><?php _e( 'Settings saved.', 'client-portal'); ?></p>
</div>
<?php
}
}
}
}
/**
* Function that enqueues the scripts on the admin settings page
*/
function cp_enqueue_admin_scripts() {
if( !empty( $_GET['page'] ) && $_GET['page'] == 'client_portal_settings' )
wp_enqueue_style( 'cp_style-back-end', plugins_url( 'assets/style.css', __FILE__ ) );
}
/**
* Function that flushes the rewrite rules when we save the settings page
*/
function cp_flush_rules(){
if( isset( $_GET['page'] ) && $_GET['page'] == 'client_portal_settings' && isset( $_REQUEST['settings-updated'] ) && $_REQUEST['settings-updated'] == 'true' ) {
flush_rewrite_rules(false);
}
}
/**
* Function that filters the WHERE clause in the select for adjacent posts so we exclude private pages
* @param $where
* @param $in_same_term
* @param $excluded_terms
* @param $taxonomy
* @param $post
* @return mixed
*/
function cp_exclude_from_post_navigation( $where, $in_same_term, $excluded_terms, $taxonomy, $post ){
if( $post->post_type == 'private-page' ){
$where = str_replace( "'private-page'", "'do not show this'", $where );
}
return $where;
}
/**
* Function that returns the id for the private page for the provided user
* @param $user_id the user id for which we want to get teh private page for
* @return mixed
*/
function cp_get_private_page_for_user( $user_id ){
$args = array(
'author' => $user_id,
'posts_per_page' => 1,
'post_type' => 'private-page',
);
$users_private_pages = get_posts( $args );
if( !empty( $users_private_pages ) ){
foreach( $users_private_pages as $users_private_page ){
return $users_private_page->ID;
break;
}
}
/* we don't have a page */
return false;
}
/**
* Function that returns all the private pages post objects
* @return array
*/
function cp_get_all_private_pages(){
$args = array(
'posts_per_page' => -1,
'numberposts' => -1,
'post_type' => 'private-page',
);
$users_private_pages = get_posts( $args );
return $users_private_pages;
}
/**
* Function that creates a custom action in the Bulk Dropdown on the Users screen
*/
function cp_create_private_page_bulk_actions(){
?>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('<option>').val('create_private_page').text( '<?php _e( 'Create Private Page', 'client-portal' ) ?>').appendTo("select[name='action'], select[name='action2']");
});
</script>
<?php
}
/**
* Function that creates a private page for the selected users in the bulk action
*/
function cp_create_private_pages_in_bulk(){
if ( !empty( $_REQUEST['users'] ) && is_array( $_REQUEST['users'] ) ) {
$users = array_map( 'absint', $_REQUEST['users'] );
foreach( $users as $user_id ){
$this->cp_create_private_page( $user_id );
}
}
}
/**
* Function that creates private pages for all existing users
*/
function cp_create_private_pages_for_all_users(){
$all_users = get_users( array( 'fields' => array( 'ID' ) ) );
if( !empty( $all_users ) ){
foreach( $all_users as $user ){
$users_private_pages = $this->cp_get_private_page_for_user( $user->ID );
if( !$users_private_pages ) {
$this->cp_create_private_page( $user->ID );
}
}
}
}
}
$CP_Object = new CL_Client_Portal();

View File

@ -1,57 +0,0 @@
=== Client Portal - Private user pages and login ===
Contributors: cozmoslabs, madalin.ungureanu, sareiodata
Donate link: http://www.cozmoslabs.com/
Tags: client portal, private user page, private pages, private content, private client page, user restricted content
Requires at least: 3.1
Tested up to: 4.7.4
Stable tag: 1.0.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
WordPress Client Portal Plugin that creates private pages for all users that only an administrator can edit.
== Description ==
The WordPress Client Portal plugin creates private pages for each user. The content for that page is accessible on the frontend only by the owner of the page
after he has logged in.
The plugin doesn't offer a login or registration form and it gives you the possibility to use a plugin of your choice.
The [client-portal] shortcode can be added to any page and when the logged in user will access that page he will be redirected to its private page.
For login and registration of users we recommend the free [Profile Builder](https://wordpress.org/plugins/profile-builder/) plugin.
You can then use the [wppb-login] shortcode in the same page as the [client-portal] shortcode.
== Installation ==
1. Upload and install the zip file via the built in WordPress plugin installer.
2. Activate the WordPress Client Portal plugin from the "Plugins" admin panel using the "Activate" link.
== Screenshots ==
1. Access the Private Page in the Users Listing in the admin area: screenshot-1.jpg
2. A Private Page in the admin area: screenshot-2.jpg
3. The Settings Page for the Plugin: screenshot-3.jpg
== Changelog ==
= 1.0.4 =
* We now have a default content option for pages
* Now private pages are excluded from appearing in frontend search
* Fixed a bug where the private page would reload indefinitely if the user hadn't a page created
* Fixed a bug where you could create duplicate pages for the same user
= 1.0.3 =
* Minor fixes and security improvements
= 1.0.2 =
* Added support for bulk Create Private Pages to Users page bulk actions
= 1.0.1 =
* Added support for comments on private user pages
* Settings page is now stylized
= 1.0.0 =
* Initial Version of the WordPress Client Portal plugin.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

View File

@ -1,367 +1,368 @@
<?php
/**
* Function that creates the "Add-Ons" submenu page
*
* @since v.2.1.0
*
* @return void
*/
function wppb_register_add_ons_submenu_page() {
add_submenu_page( 'profile-builder', __( 'Add-Ons', 'profile-builder' ), __( 'Add-Ons', 'profile-builder' ), 'manage_options', 'profile-builder-add-ons', 'wppb_add_ons_content' );
}
add_action( 'admin_menu', 'wppb_register_add_ons_submenu_page', 19 );
/**
* Function that adds content to the "Add-Ons" submenu page
*
* @since v.2.1.0
*
* @return string
*/
function wppb_add_ons_content() {
$version = 'Free';
$version = ( ( PROFILE_BUILDER == 'Profile Builder Pro' ) ? 'Pro' : $version );
$version = ( ( PROFILE_BUILDER == 'Profile Builder Hobbyist' ) ? 'Hobbyist' : $version );
?>
<div class="wrap wppb-add-on-wrap">
<h2><?php _e( 'Add-Ons', 'profile-builder' ); ?></h2>
<span id="wppb-add-on-activate-button-text" class="wppb-add-on-user-messages"><?php echo __( 'Activate', 'profile-builder' ); ?></span>
<span id="wppb-add-on-downloading-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Downloading and installing...', 'profile-builder' ); ?></span>
<span id="wppb-add-on-download-finished-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Installation complete', 'profile-builder' ); ?></span>
<span id="wppb-add-on-activated-button-text" class="wppb-add-on-user-messages"><?php echo __( 'Add-On is Active', 'profile-builder' ); ?></span>
<span id="wppb-add-on-activated-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Add-On has been activated', 'profile-builder' ) ?></span>
<span id="wppb-add-on-activated-error-button-text" class="wppb-add-on-user-messages"><?php echo __( 'Retry Install', 'profile-builder' ) ?></span>
<span id="wppb-add-on-is-active-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Add-On is <strong>active</strong>', 'profile-builder' ); ?></span>
<span id="wppb-add-on-is-not-active-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Add-On is <strong>inactive</strong>', 'profile-builder' ); ?></span>
<span id="wppb-add-on-deactivate-button-text" class="wppb-add-on-user-messages"><?php echo __( 'Deactivate', 'profile-builder' ) ?></span>
<span id="wppb-add-on-deactivated-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Add-On has been deactivated.', 'profile-builder' ) ?></span>
<div id="the-list">
<?php
$wppb_add_ons = wppb_add_ons_get_remote_content();
$wppb_get_all_plugins = get_plugins();
$wppb_get_active_plugins = get_option('active_plugins');
if( $wppb_add_ons === false ) {
echo __('Something went wrong, we could not connect to the server. Please try again later.', 'profile-builder');
} else {
foreach( $wppb_add_ons as $key => $wppb_add_on ) {
$wppb_add_on_exists = 0;
$wppb_add_on_is_active = 0;
$wppb_add_on_is_network_active = 0;
// Check to see if add-on is in the plugins folder
foreach ($wppb_get_all_plugins as $wppb_plugin_key => $wppb_plugin) {
if (strpos(strtolower($wppb_plugin['Name']), strtolower($wppb_add_on['name'])) !== false && strpos(strtolower($wppb_plugin['AuthorName']), strtolower('Cozmoslabs')) !== false) {
$wppb_add_on_exists = 1;
if (in_array($wppb_plugin_key, $wppb_get_active_plugins)) {
$wppb_add_on_is_active = 1;
}
// Consider the add-on active if it's network active
if (is_plugin_active_for_network($wppb_plugin_key)) {
$wppb_add_on_is_network_active = 1;
$wppb_add_on_is_active = 1;
}
$wppb_add_on['plugin_file'] = $wppb_plugin_key;
}
}
echo '<div class="plugin-card wppb-add-on">';
echo '<div class="plugin-card-top">';
echo '<a target="_blank" href="' . $wppb_add_on['url'] . '?utm_source=wpbackend&utm_medium=clientsite&utm_content=add-on-page&utm_campaign=PB' . $version . '">';
echo '<img src="' . $wppb_add_on['thumbnail_url'] . '" />';
echo '</a>';
echo '<h3 class="wppb-add-on-title">';
echo '<a target="_blank" href="' . $wppb_add_on['url'] . '?utm_source=wpbackend&utm_medium=clientsite&utm_content=add-on-page&utm_campaign=PB' . $version . '">';
echo $wppb_add_on['name'];
echo '</a>';
echo '</h3>';
//echo '<h3 class="wppb-add-on-price">' . $wppb_add_on['price'] . '</h3>';
if( $wppb_add_on['type'] == 'paid' )
echo '<h3 class="wppb-add-on-price">' . __( 'Available in Hobbyist and Pro Versions', 'profile-builder' ) . '</h3>';
else
echo '<h3 class="wppb-add-on-price">' . __( 'Available in All Versions', 'profile-builder' ) . '</h3>';
echo '<p class="wppb-add-on-description">' . $wppb_add_on['description'] . '</p>';
echo '</div>';
$wppb_version_validation = version_compare(PROFILE_BUILDER_VERSION, $wppb_add_on['product_version']);
($wppb_version_validation != -1) ? $wppb_version_validation_class = 'wppb-add-on-compatible' : $wppb_version_validation_class = 'wppb-add-on-not-compatible';
echo '<div class="plugin-card-bottom ' . $wppb_version_validation_class . '">';
// PB minimum version number is all good
if ($wppb_version_validation != -1) {
// PB version type does match
if (in_array(strtolower($version), $wppb_add_on['product_version_type'])) {
$ajax_nonce = wp_create_nonce("wppb-activate-addon");
if ($wppb_add_on_exists) {
// Display activate/deactivate buttons
if (!$wppb_add_on_is_active) {
echo '<a class="wppb-add-on-activate right button button-secondary" href="' . $wppb_add_on['plugin_file'] . '" data-nonce="' . $ajax_nonce . '">' . __('Activate', 'profile-builder') . '</a>';
// If add-on is network activated don't allow deactivation
} elseif (!$wppb_add_on_is_network_active) {
echo '<a class="wppb-add-on-deactivate right button button-secondary" href="' . $wppb_add_on['plugin_file'] . '" data-nonce="' . $ajax_nonce . '">' . __('Deactivate', 'profile-builder') . '</a>';
}
// Display message to the user
if (!$wppb_add_on_is_active) {
echo '<span class="dashicons dashicons-no-alt"></span><span class="wppb-add-on-message">' . __('Add-On is <strong>inactive</strong>', 'profile-builder') . '</span>';
} else {
echo '<span class="dashicons dashicons-yes"></span><span class="wppb-add-on-message">' . __('Add-On is <strong>active</strong>', 'profile-builder') . '</span>';
}
} else {
// If we're on a multisite don't add the wpp-add-on-download class to the button so we don't fire the js that
// handles the in-page download
($wppb_add_on['paid']) ? $wppb_paid_link_class = 'button-primary' : $wppb_paid_link_class = 'button-secondary';
($wppb_add_on['paid']) ? $wppb_paid_link_text = __('Learn More', 'profile-builder') : $wppb_paid_link_text = __('Download Now', 'profile-builder');
($wppb_add_on['paid']) ? $wppb_paid_href_utm_text = '?utm_source=wpbackend&utm_medium=clientsite&utm_content=add-on-page-buy-button&utm_campaign=PB' . $version : $wppb_paid_href_utm_text = '?utm_source=wpbackend&utm_medium=clientsite&utm_content=add-on-page&utm_campaign=PB' . $version;
echo '<a target="_blank" class="right button ' . $wppb_paid_link_class . '" href="' . $wppb_add_on['url'] . $wppb_paid_href_utm_text . '" data-add-on-slug="profile-builder-' . $wppb_add_on['slug'] . '" data-add-on-name="' . $wppb_add_on['name'] . '" data-nonce="' . $ajax_nonce . '">' . $wppb_paid_link_text . '</a>';
echo '<span class="dashicons dashicons-yes"></span><span class="wppb-add-on-message">' . __('Compatible with your version of Profile Builder.', 'profile-builder') . '</span>';
}
echo '<div class="spinner"></div>';
// PB version type does not match
} else {
echo '<a target="_blank" class="button button-secondary right" href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wpbackend&utm_medium=clientsite&utm_content=add-on-page-upgrade-button&utm_campaign=PB' . $version . '">' . __('Upgrade Profile Builder', 'profile-builder') . '</a>';
echo '<span class="dashicons dashicons-no-alt"></span><span class="wppb-add-on-message">' . __('Not compatible with Profile Builder', 'profile-builder') . ' ' . $version . '</span>';
}
} else {
// If PB version is older than the minimum required version of the add-on
echo ' ' . '<a class="button button-secondary right" href="' . admin_url('plugins.php') . '">' . __('Update', 'profile-builder') . '</a>';
echo '<span class="wppb-add-on-message">' . __('Not compatible with your version of Profile Builder.', 'profile-builder') . '</span><br />';
echo '<span class="wppb-add-on-message">' . __('Minimum required Profile Builder version:', 'profile-builder') . '<strong> ' . $wppb_add_on['product_version'] . '</strong></span>';
}
// We had to put this error here because we need the url of the add-on
echo '<span class="wppb-add-on-user-messages wppb-error-manual-install">' . sprintf(__('Could not install add-on. Retry or <a href="%s" target="_blank">install manually</a>.', 'profile-builder'), esc_url($wppb_add_on['url'])) . '</span>';
echo '</div>';
echo '</div>';
} /* end $wppb_add_ons foreach */
}
?>
</div>
<div class="clear"></div>
<div>
<h2><?php _e( 'Recommended Plugins', 'profile-builder' ) ?></h2>
<?php
$pms_add_on_exists = 0;
$pms_add_on_is_active = 0;
$pms_add_on_is_network_active = 0;
// Check to see if add-on is in the plugins folder
foreach ($wppb_get_all_plugins as $wppb_plugin_key => $wppb_plugin) {
if( strtolower($wppb_plugin['Name']) == strtolower( 'Paid Member Subscriptions' ) && strpos(strtolower($wppb_plugin['AuthorName']), strtolower('Cozmoslabs')) !== false) {
$pms_add_on_exists = 1;
if (in_array($wppb_plugin_key, $wppb_get_active_plugins)) {
$pms_add_on_is_active = 1;
}
// Consider the add-on active if it's network active
if (is_plugin_active_for_network($wppb_plugin_key)) {
$pms_add_on_is_network_active = 1;
$pms_add_on_is_active = 1;
}
$plugin_file = $wppb_plugin_key;
}
}
?>
<div class="plugin-card wppb-recommended-plugin wppb-add-on">
<div class="plugin-card-top">
<a target="_blank" href="http://wordpress.org/plugins/paid-member-subscriptions/">
<img src="<?php echo plugins_url( '../assets/images/pms-recommended.png', __FILE__ ); ?>" width="100%">
</a>
<h3 class="wppb-add-on-title">
<a target="_blank" href="http://wordpress.org/plugins/paid-member-subscriptions/">Paid Member Subscriptions</a>
</h3>
<h3 class="wppb-add-on-price"><?php _e( 'Free', 'profile-builder' ) ?></h3>
<p class="wppb-add-on-description">
<?php _e( 'Accept user payments, create subscription plans and restrict content on your membership site.', 'profile-builder' ) ?>
<a href="<?php admin_url();?>plugin-install.php?tab=plugin-information&plugin=paid-member-subscriptions&TB_iframe=true&width=772&height=875" class="thickbox" aria-label="More information about Paid Member Subscriptions - membership & content restriction" data-title="Paid Member Subscriptions - membership & content restriction"><?php _e( 'More Details' ); ?></a>
</p>
</div>
<div class="plugin-card-bottom wppb-add-on-compatible">
<?php
if ($pms_add_on_exists) {
// Display activate/deactivate buttons
if (!$pms_add_on_is_active) {
echo '<a class="wppb-add-on-activate right button button-secondary" href="' . $plugin_file . '" data-nonce="' . $ajax_nonce . '">' . __('Activate', 'profile-builder') . '</a>';
// If add-on is network activated don't allow deactivation
} elseif (!$pms_add_on_is_network_active) {
echo '<a class="wppb-add-on-deactivate right button button-secondary" href="' . $plugin_file . '" data-nonce="' . $ajax_nonce . '">' . __('Deactivate', 'profile-builder') . '</a>';
}
// Display message to the user
if( !$pms_add_on_is_active ){
echo '<span class="dashicons dashicons-no-alt"></span><span class="wppb-add-on-message">' . __('Plugin is <strong>inactive</strong>', 'profile-builder') . '</span>';
} else {
echo '<span class="dashicons dashicons-yes"></span><span class="wppb-add-on-message">' . __('Plugin is <strong>active</strong>', 'profile-builder') . '</span>';
}
} else {
// handles the in-page download
$wppb_paid_link_class = 'button-secondary';
$wppb_paid_link_text = __('Download Now', 'profile-builder');
echo '<a target="_blank" class="right button ' . $wppb_paid_link_class . '" href="https://downloads.wordpress.org/plugin/paid-member-subscriptions.zip" data-add-on-slug="paid-member-subscriptions" data-add-on-name="Paid Member Subscriptions" data-nonce="' . $ajax_nonce . '">' . $wppb_paid_link_text . '</a>';
echo '<span class="dashicons dashicons-yes"></span><span class="wppb-add-on-message">' . __('Compatible with your version of Profile Builder.', 'profile-builder') . '</span>';
}
?>
<div class="spinner"></div>
<span class="wppb-add-on-user-messages wppb-error-manual-install"><?php printf(__('Could not install plugin. Retry or <a href="%s" target="_blank">install manually</a>.', 'profile-builder'), esc_url( 'http://www.wordpress.org/plugins/paid-member-subscriptions' )) ?></a>.</span>
</div>
</div>
</div>
</div>
<?php
}
/*
* Function that returns the array of add-ons from cozmoslabs.com if it finds the file
* If something goes wrong it returns false
*
* @since v.2.1.0
*/
function wppb_add_ons_get_remote_content() {
$response = wp_remote_get('https://www.cozmoslabs.com/wp-content/plugins/cozmoslabs-products-add-ons/profile-builder-add-ons.json');
if( is_wp_error($response) ) {
return false;
} else {
$json_file_contents = $response['body'];
$wppb_add_ons = json_decode( $json_file_contents, true );
}
if( !is_object( $wppb_add_ons ) && !is_array( $wppb_add_ons ) ) {
return false;
}
return $wppb_add_ons;
}
/*
* Function that is triggered through Ajax to activate an add-on
*
* @since v.2.1.0
*/
function wppb_add_on_activate() {
check_ajax_referer( 'wppb-activate-addon', 'nonce' );
if( current_user_can( 'manage_options' ) ){
// Setup variables from POST
$wppb_add_on_to_activate = sanitize_text_field( $_POST['wppb_add_on_to_activate'] );
$response = filter_var( $_POST['wppb_add_on_index'], FILTER_SANITIZE_NUMBER_INT );
if( !empty( $wppb_add_on_to_activate ) && !is_plugin_active( $wppb_add_on_to_activate )) {
activate_plugin( $wppb_add_on_to_activate );
}
if( !empty( $response ) )
echo $response;
}
wp_die();
}
add_action( 'wp_ajax_wppb_add_on_activate', 'wppb_add_on_activate' );
/*
* Function that is triggered through Ajax to deactivate an add-on
*
* @since v.2.1.0
*/
function wppb_add_on_deactivate() {
check_ajax_referer( 'wppb-activate-addon', 'nonce' );
if( current_user_can( 'manage_options' ) ){
// Setup variables from POST
$wppb_add_on_to_deactivate = sanitize_text_field( $_POST['wppb_add_on_to_deactivate'] );
$response = filter_var( $_POST['wppb_add_on_index'], FILTER_SANITIZE_NUMBER_INT );
if( !empty( $wppb_add_on_to_deactivate ))
deactivate_plugins( $wppb_add_on_to_deactivate );
if( !empty( $response ) )
echo $response;
}
wp_die();
}
add_action( 'wp_ajax_wppb_add_on_deactivate', 'wppb_add_on_deactivate' );
/*
* Function that retrieves the data of the newly added plugin
*
* @since v.2.1.0
*/
function wppb_add_on_get_new_plugin_data() {
if(isset( $_POST['wppb_add_on_name'] ) ){
$wppb_add_on_name = sanitize_text_field( $_POST['wppb_add_on_name'] );
}
$wppb_get_all_plugins = get_plugins();
foreach( $wppb_get_all_plugins as $wppb_plugin_key => $wppb_plugin ) {
if( strpos( $wppb_plugin['Name'], $wppb_add_on_name ) !== false && strpos( $wppb_plugin['AuthorName'], 'Cozmoslabs' ) !== false ) {
// Deactivate the add-on if it's active
if( is_plugin_active( $wppb_plugin_key )) {
deactivate_plugins( $wppb_plugin_key );
}
// Return the plugin path
echo $wppb_plugin_key;
wp_die();
}
}
wp_die();
}
add_action( 'wp_ajax_wppb_add_on_get_new_plugin_data', 'wppb_add_on_get_new_plugin_data' );
<?php
/**
* Function that creates the "Add-Ons" submenu page
*
* @since v.2.1.0
*
* @return void
*/
function wppb_register_add_ons_submenu_page() {
add_submenu_page( 'profile-builder', __( 'Add-Ons', 'profile-builder' ), __( 'Add-Ons', 'profile-builder' ), 'manage_options', 'profile-builder-add-ons', 'wppb_add_ons_content' );
}
add_action( 'admin_menu', 'wppb_register_add_ons_submenu_page', 19 );
/**
* Function that adds content to the "Add-Ons" submenu page
*
* @since v.2.1.0
*
* @return string
*/
function wppb_add_ons_content() {
$version = 'Free';
$version = ( ( PROFILE_BUILDER == 'Profile Builder Pro' ) ? 'Pro' : $version );
$version = ( ( PROFILE_BUILDER == 'Profile Builder Hobbyist' ) ? 'Hobbyist' : $version );
?>
<div class="wrap wppb-add-on-wrap">
<h2><?php _e( 'Add-Ons', 'profile-builder' ); ?></h2>
<span id="wppb-add-on-activate-button-text" class="wppb-add-on-user-messages"><?php echo __( 'Activate', 'profile-builder' ); ?></span>
<span id="wppb-add-on-downloading-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Downloading and installing...', 'profile-builder' ); ?></span>
<span id="wppb-add-on-download-finished-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Installation complete', 'profile-builder' ); ?></span>
<span id="wppb-add-on-activated-button-text" class="wppb-add-on-user-messages"><?php echo __( 'Add-On is Active', 'profile-builder' ); ?></span>
<span id="wppb-add-on-activated-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Add-On has been activated', 'profile-builder' ) ?></span>
<span id="wppb-add-on-activated-error-button-text" class="wppb-add-on-user-messages"><?php echo __( 'Retry Install', 'profile-builder' ) ?></span>
<span id="wppb-add-on-is-active-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Add-On is <strong>active</strong>', 'profile-builder' ); ?></span>
<span id="wppb-add-on-is-not-active-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Add-On is <strong>inactive</strong>', 'profile-builder' ); ?></span>
<span id="wppb-add-on-deactivate-button-text" class="wppb-add-on-user-messages"><?php echo __( 'Deactivate', 'profile-builder' ) ?></span>
<span id="wppb-add-on-deactivated-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Add-On has been deactivated.', 'profile-builder' ) ?></span>
<div id="the-list">
<?php
$wppb_add_ons = wppb_add_ons_get_remote_content();
$wppb_get_all_plugins = get_plugins();
$wppb_get_active_plugins = get_option('active_plugins');
if( $wppb_add_ons === false ) {
echo __('Something went wrong, we could not connect to the server. Please try again later.', 'profile-builder');
} else {
foreach( $wppb_add_ons as $key => $wppb_add_on ) {
$wppb_add_on_exists = 0;
$wppb_add_on_is_active = 0;
$wppb_add_on_is_network_active = 0;
// Check to see if add-on is in the plugins folder
foreach ($wppb_get_all_plugins as $wppb_plugin_key => $wppb_plugin) {
if (strpos(strtolower($wppb_plugin['Name']), strtolower($wppb_add_on['name'])) !== false && strpos(strtolower($wppb_plugin['AuthorName']), strtolower('Cozmoslabs')) !== false) {
$wppb_add_on_exists = 1;
if (in_array($wppb_plugin_key, $wppb_get_active_plugins)) {
$wppb_add_on_is_active = 1;
}
// Consider the add-on active if it's network active
if (is_plugin_active_for_network($wppb_plugin_key)) {
$wppb_add_on_is_network_active = 1;
$wppb_add_on_is_active = 1;
}
$wppb_add_on['plugin_file'] = $wppb_plugin_key;
}
}
echo '<div class="plugin-card wppb-add-on">';
echo '<div class="plugin-card-top">';
echo '<a target="_blank" href="' . $wppb_add_on['url'] . '?utm_source=wpbackend&utm_medium=clientsite&utm_content=add-on-page&utm_campaign=PB' . $version . '">';
echo '<img src="' . $wppb_add_on['thumbnail_url'] . '" />';
echo '</a>';
echo '<h3 class="wppb-add-on-title">';
echo '<a target="_blank" href="' . $wppb_add_on['url'] . '?utm_source=wpbackend&utm_medium=clientsite&utm_content=add-on-page&utm_campaign=PB' . $version . '">';
echo $wppb_add_on['name'];
echo '</a>';
echo '</h3>';
//echo '<h3 class="wppb-add-on-price">' . $wppb_add_on['price'] . '</h3>';
/*
if( $wppb_add_on['type'] == 'paid' )
echo '<h3 class="wppb-add-on-price">' . __( 'Available in Hobbyist and Pro Versions', 'profile-builder' ) . '</h3>';
else
echo '<h3 class="wppb-add-on-price">' . __( 'Available in All Versions', 'profile-builder' ) . '</h3>';
*/
echo '<p class="wppb-add-on-description">' . $wppb_add_on['description'] . '</p>';
echo '</div>';
$wppb_version_validation = version_compare(PROFILE_BUILDER_VERSION, $wppb_add_on['product_version']);
($wppb_version_validation != -1) ? $wppb_version_validation_class = 'wppb-add-on-compatible' : $wppb_version_validation_class = 'wppb-add-on-not-compatible';
echo '<div class="plugin-card-bottom ' . $wppb_version_validation_class . '">';
// PB minimum version number is all good
if ($wppb_version_validation != -1) {
// PB version type does match
if (in_array(strtolower($version), $wppb_add_on['product_version_type'])) {
$ajax_nonce = wp_create_nonce("wppb-activate-addon");
if ($wppb_add_on_exists) {
// Display activate/deactivate buttons
if (!$wppb_add_on_is_active) {
echo '<a class="wppb-add-on-activate right button button-secondary" href="' . $wppb_add_on['plugin_file'] . '" data-nonce="' . $ajax_nonce . '">' . __('Activate', 'profile-builder') . '</a>';
// If add-on is network activated don't allow deactivation
} elseif (!$wppb_add_on_is_network_active) {
echo '<a class="wppb-add-on-deactivate right button button-secondary" href="' . $wppb_add_on['plugin_file'] . '" data-nonce="' . $ajax_nonce . '">' . __('Deactivate', 'profile-builder') . '</a>';
}
// Display message to the user
if (!$wppb_add_on_is_active) {
echo '<span class="dashicons dashicons-no-alt"></span><span class="wppb-add-on-message">' . __('Add-On is <strong>inactive</strong>', 'profile-builder') . '</span>';
} else {
echo '<span class="dashicons dashicons-yes"></span><span class="wppb-add-on-message">' . __('Add-On is <strong>active</strong>', 'profile-builder') . '</span>';
}
} else {
// If we're on a multisite don't add the wpp-add-on-download class to the button so we don't fire the js that
// handles the in-page download
($wppb_add_on['paid']) ? $wppb_paid_link_class = 'button-primary' : $wppb_paid_link_class = 'button-secondary';
($wppb_add_on['paid']) ? $wppb_paid_link_text = __('Learn More', 'profile-builder') : $wppb_paid_link_text = __('Download Now', 'profile-builder');
($wppb_add_on['paid']) ? $wppb_paid_href_utm_text = '?utm_source=wpbackend&utm_medium=clientsite&utm_content=add-on-page-buy-button&utm_campaign=PB' . $version : $wppb_paid_href_utm_text = '?utm_source=wpbackend&utm_medium=clientsite&utm_content=add-on-page&utm_campaign=PB' . $version;
echo '<a target="_blank" class="right button ' . $wppb_paid_link_class . '" href="' . $wppb_add_on['url'] . $wppb_paid_href_utm_text . '" data-add-on-slug="profile-builder-' . $wppb_add_on['slug'] . '" data-add-on-name="' . $wppb_add_on['name'] . '" data-nonce="' . $ajax_nonce . '">' . $wppb_paid_link_text . '</a>';
echo '<span class="dashicons dashicons-yes"></span><span class="wppb-add-on-message">' . __('Compatible with your version of Profile Builder.', 'profile-builder') . '</span>';
}
echo '<div class="spinner"></div>';
// PB version type does not match
} else {
echo '<a target="_blank" class="button button-secondary right" href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wpbackend&utm_medium=clientsite&utm_content=add-on-page-upgrade-button&utm_campaign=PB' . $version . '">' . __('Upgrade Profile Builder', 'profile-builder') . '</a>';
echo '<span class="dashicons dashicons-no-alt"></span><span class="wppb-add-on-message">' . __('Not compatible with Profile Builder', 'profile-builder') . ' ' . $version . '</span>';
}
} else {
// If PB version is older than the minimum required version of the add-on
echo ' ' . '<a class="button button-secondary right" href="' . admin_url('plugins.php') . '">' . __('Update', 'profile-builder') . '</a>';
echo '<span class="wppb-add-on-message">' . __('Not compatible with your version of Profile Builder.', 'profile-builder') . '</span><br />';
echo '<span class="wppb-add-on-message">' . __('Minimum required Profile Builder version:', 'profile-builder') . '<strong> ' . $wppb_add_on['product_version'] . '</strong></span>';
}
// We had to put this error here because we need the url of the add-on
echo '<span class="wppb-add-on-user-messages wppb-error-manual-install">' . sprintf(__('Could not install add-on. Retry or <a href="%s" target="_blank">install manually</a>.', 'profile-builder'), esc_url($wppb_add_on['url'])) . '</span>';
echo '</div>';
echo '</div>';
} /* end $wppb_add_ons foreach */
}
?>
</div>
<div class="clear"></div>
<div>
<h2><?php _e( 'Recommended Plugins', 'profile-builder' ) ?></h2>
<?php
$pms_add_on_exists = 0;
$pms_add_on_is_active = 0;
$pms_add_on_is_network_active = 0;
// Check to see if add-on is in the plugins folder
foreach ($wppb_get_all_plugins as $wppb_plugin_key => $wppb_plugin) {
if( strtolower($wppb_plugin['Name']) == strtolower( 'Paid Member Subscriptions' ) && strpos(strtolower($wppb_plugin['AuthorName']), strtolower('Cozmoslabs')) !== false) {
$pms_add_on_exists = 1;
if (in_array($wppb_plugin_key, $wppb_get_active_plugins)) {
$pms_add_on_is_active = 1;
}
// Consider the add-on active if it's network active
if (is_plugin_active_for_network($wppb_plugin_key)) {
$pms_add_on_is_network_active = 1;
$pms_add_on_is_active = 1;
}
$plugin_file = $wppb_plugin_key;
}
}
?>
<div class="plugin-card wppb-recommended-plugin wppb-add-on">
<div class="plugin-card-top">
<a target="_blank" href="http://wordpress.org/plugins/paid-member-subscriptions/">
<img src="<?php echo plugins_url( '../assets/images/pms-recommended.png', __FILE__ ); ?>" width="100%">
</a>
<h3 class="wppb-add-on-title">
<a target="_blank" href="http://wordpress.org/plugins/paid-member-subscriptions/">Paid Member Subscriptions</a>
</h3>
<h3 class="wppb-add-on-price"><?php _e( 'Free', 'profile-builder' ) ?></h3>
<p class="wppb-add-on-description">
<?php _e( 'Accept user payments, create subscription plans and restrict content on your membership site.', 'profile-builder' ) ?>
<a href="<?php admin_url();?>plugin-install.php?tab=plugin-information&plugin=paid-member-subscriptions&TB_iframe=true&width=772&height=875" class="thickbox" aria-label="More information about Paid Member Subscriptions - membership & content restriction" data-title="Paid Member Subscriptions - membership & content restriction"><?php _e( 'More Details' ); ?></a>
</p>
</div>
<div class="plugin-card-bottom wppb-add-on-compatible">
<?php
if ($pms_add_on_exists) {
// Display activate/deactivate buttons
if (!$pms_add_on_is_active) {
echo '<a class="wppb-add-on-activate right button button-secondary" href="' . $plugin_file . '" data-nonce="' . $ajax_nonce . '">' . __('Activate', 'profile-builder') . '</a>';
// If add-on is network activated don't allow deactivation
} elseif (!$pms_add_on_is_network_active) {
echo '<a class="wppb-add-on-deactivate right button button-secondary" href="' . $plugin_file . '" data-nonce="' . $ajax_nonce . '">' . __('Deactivate', 'profile-builder') . '</a>';
}
// Display message to the user
if( !$pms_add_on_is_active ){
echo '<span class="dashicons dashicons-no-alt"></span><span class="wppb-add-on-message">' . __('Plugin is <strong>inactive</strong>', 'profile-builder') . '</span>';
} else {
echo '<span class="dashicons dashicons-yes"></span><span class="wppb-add-on-message">' . __('Plugin is <strong>active</strong>', 'profile-builder') . '</span>';
}
} else {
// handles the in-page download
$wppb_paid_link_class = 'button-secondary';
$wppb_paid_link_text = __('Download Now', 'profile-builder');
echo '<a target="_blank" class="right button ' . $wppb_paid_link_class . '" href="https://downloads.wordpress.org/plugin/paid-member-subscriptions.zip" data-add-on-slug="paid-member-subscriptions" data-add-on-name="Paid Member Subscriptions" data-nonce="' . $ajax_nonce . '">' . $wppb_paid_link_text . '</a>';
echo '<span class="dashicons dashicons-yes"></span><span class="wppb-add-on-message">' . __('Compatible with your version of Profile Builder.', 'profile-builder') . '</span>';
}
?>
<div class="spinner"></div>
<span class="wppb-add-on-user-messages wppb-error-manual-install"><?php printf(__('Could not install plugin. Retry or <a href="%s" target="_blank">install manually</a>.', 'profile-builder'), esc_url( 'http://www.wordpress.org/plugins/paid-member-subscriptions' )) ?></a>.</span>
</div>
</div>
</div>
</div>
<?php
}
/*
* Function that returns the array of add-ons from cozmoslabs.com if it finds the file
* If something goes wrong it returns false
*
* @since v.2.1.0
*/
function wppb_add_ons_get_remote_content() {
$response = wp_remote_get('https://www.cozmoslabs.com/wp-content/plugins/cozmoslabs-products-add-ons/profile-builder-add-ons.json');
if( is_wp_error($response) ) {
return false;
} else {
$json_file_contents = $response['body'];
$wppb_add_ons = json_decode( $json_file_contents, true );
}
if( !is_object( $wppb_add_ons ) && !is_array( $wppb_add_ons ) ) {
return false;
}
return $wppb_add_ons;
}
/*
* Function that is triggered through Ajax to activate an add-on
*
* @since v.2.1.0
*/
function wppb_add_on_activate() {
check_ajax_referer( 'wppb-activate-addon', 'nonce' );
if( current_user_can( 'manage_options' ) ){
// Setup variables from POST
$wppb_add_on_to_activate = sanitize_text_field( $_POST['wppb_add_on_to_activate'] );
$response = filter_var( $_POST['wppb_add_on_index'], FILTER_SANITIZE_NUMBER_INT );
if( !empty( $wppb_add_on_to_activate ) && !is_plugin_active( $wppb_add_on_to_activate )) {
activate_plugin( $wppb_add_on_to_activate );
}
if( !empty( $response ) )
echo $response;
}
wp_die();
}
add_action( 'wp_ajax_wppb_add_on_activate', 'wppb_add_on_activate' );
/*
* Function that is triggered through Ajax to deactivate an add-on
*
* @since v.2.1.0
*/
function wppb_add_on_deactivate() {
check_ajax_referer( 'wppb-activate-addon', 'nonce' );
if( current_user_can( 'manage_options' ) ){
// Setup variables from POST
$wppb_add_on_to_deactivate = sanitize_text_field( $_POST['wppb_add_on_to_deactivate'] );
$response = filter_var( $_POST['wppb_add_on_index'], FILTER_SANITIZE_NUMBER_INT );
if( !empty( $wppb_add_on_to_deactivate ))
deactivate_plugins( $wppb_add_on_to_deactivate );
if( !empty( $response ) )
echo $response;
}
wp_die();
}
add_action( 'wp_ajax_wppb_add_on_deactivate', 'wppb_add_on_deactivate' );
/*
* Function that retrieves the data of the newly added plugin
*
* @since v.2.1.0
*/
function wppb_add_on_get_new_plugin_data() {
if(isset( $_POST['wppb_add_on_name'] ) ){
$wppb_add_on_name = sanitize_text_field( $_POST['wppb_add_on_name'] );
}
$wppb_get_all_plugins = get_plugins();
foreach( $wppb_get_all_plugins as $wppb_plugin_key => $wppb_plugin ) {
if( strpos( $wppb_plugin['Name'], $wppb_add_on_name ) !== false && strpos( $wppb_plugin['AuthorName'], 'Cozmoslabs' ) !== false ) {
// Deactivate the add-on if it's active
if( is_plugin_active( $wppb_plugin_key )) {
deactivate_plugins( $wppb_plugin_key );
}
// Return the plugin path
echo $wppb_plugin_key;
wp_die();
}
}
wp_die();
}
add_action( 'wp_ajax_wppb_add_on_get_new_plugin_data', 'wppb_add_on_get_new_plugin_data' );

View File

@ -1,121 +1,121 @@
<?php
/**
* Function that creates the "Show/Hide the Admin Bar on the Front-End" submenu page
*
* @since v.2.0
*
* @return void
*/
function wppb_show_hide_admin_bar_submenu_page() {
add_submenu_page( 'profile-builder', __( 'Show/Hide the Admin Bar on the Front-End', 'profile-builder' ), __( 'Admin Bar Settings', 'profile-builder' ), 'manage_options', 'profile-builder-admin-bar-settings', 'wppb_show_hide_admin_bar_content' );
}
add_action( 'admin_menu', 'wppb_show_hide_admin_bar_submenu_page', 4 );
function wppb_generate_admin_bar_default_values( $roles ){
$wppb_display_admin_settings = get_option( 'wppb_display_admin_settings', 'not_found' );
if ( $wppb_display_admin_settings == 'not_found' ){
if( !empty( $roles ) ){
$admin_settings = array();
foreach ( $roles as $role ){
if( !empty( $role['name'] ) )
$admin_settings[$role['name']] = 'default';
}
update_option( 'wppb_display_admin_settings', $admin_settings );
}
}
}
/**
* Function that adds content to the "Show/Hide the Admin Bar on the Front-End" submenu page
*
* @since v.2.0
*
* @return string
*/
function wppb_show_hide_admin_bar_content() {
global $wp_roles;
wppb_generate_admin_bar_default_values( $wp_roles );
?>
<div class="wrap wppb-wrap wppb-admin-bar">
<h2><?php _e( 'Admin Bar Settings', 'profile-builder' );?></h2>
<p><?php _e( 'Choose which user roles view the admin bar in the front-end of the website.', 'profile-builder' ); ?>
<form method="post" action="options.php#show-hide-admin-bar">
<?php
$admin_bar_settings = get_option( 'wppb_display_admin_settings' );
settings_fields( 'wppb_display_admin_settings' );
?>
<table class="widefat">
<thead>
<tr>
<th class="row-title" scope="col"><?php _e('User-Role', 'profile-builder');?></th>
<th scope="col"><?php _e('Visibility', 'profile-builder');?></th>
</tr>
</thead>
<tbody>
<?php
$alt_i = 0;
foreach ( $wp_roles->roles as $role ) {
$alt_i++;
$key = $role['name'];
$setting_exists = !empty( $admin_bar_settings[$key] );
$alt_class = ( ( $alt_i%2 == 0 ) ? ' class="alternate"' : '' );
echo'<tr'.$alt_class.'>
<td>'.translate_user_role($key).'</td>
<td>
<span><input id="rd'.$key.'" type="radio" name="wppb_display_admin_settings['.$key.']" value="default"'.( ( !$setting_exists || $admin_bar_settings[$key] == 'default' ) ? ' checked' : '' ).'/><label for="rd'.$key.'">'.__( 'Default', 'profile-builder' ).'</label></span>
<span><input id="rs'.$key.'" type="radio" name="wppb_display_admin_settings['.$key.']" value="show"'.( ( $setting_exists && $admin_bar_settings[$key] == 'show') ? ' checked' : '' ).'/><label for="rs'.$key.'">'.__( 'Show', 'profile-builder' ).'</label></span>
<span><input id="rh'.$key.'" type="radio" name="wppb_display_admin_settings['.$key.']" value="hide"'.( ( $setting_exists && $admin_bar_settings[$key] == 'hide') ? ' checked' : '' ).'/><label for="rh'.$key.'">'.__( 'Hide', 'profile-builder' ).'</label></span>
</td>
</tr>';
}
?>
</table>
<div id="wppb_submit_button_div">
<input type="hidden" name="action" value="update" />
<p class="submit">
<input type="submit" class="button-primary" value="<?php _e( 'Save Changes' ) ?>" />
</p>
</div>
</form>
</div>
<?php
}
/**
* Function that changes the username on the top right menu (admin bar)
*
* @since v.2.0
*
* @return string
*/
function wppb_replace_username_on_admin_bar( $wp_admin_bar ) {
$wppb_general_settings = get_option( 'wppb_general_settings' );
if ( isset( $wppb_general_settings['loginWith'] ) && ( $wppb_general_settings['loginWith'] == 'email' ) ){
$current_user = wp_get_current_user();
if ( $current_user->ID != 0 ) {
$my_account_main = $wp_admin_bar->get_node('my-account');
$new_title1 = str_replace($current_user->display_name, $current_user->user_email, $my_account_main->title);
$wp_admin_bar->add_node(array('id' => 'my-account', 'title' => $new_title1));
$my_account_sub = $wp_admin_bar->get_node('user-info');
$wp_admin_bar->add_node(array('parent' => 'user-actions', 'id' => 'user-info', 'title' => get_avatar($current_user->ID, 64) . "<span class='display-name'>{$current_user->user_email}</span>", 'href' => get_edit_profile_url($current_user->ID), 'meta' => array('tabindex' => -1)));
}
}
return $wp_admin_bar;
}
<?php
/**
* Function that creates the "Show/Hide the Admin Bar on the Front-End" submenu page
*
* @since v.2.0
*
* @return void
*/
function wppb_show_hide_admin_bar_submenu_page() {
add_submenu_page( 'profile-builder', __( 'Show/Hide the Admin Bar on the Front-End', 'profile-builder' ), __( 'Admin Bar Settings', 'profile-builder' ), 'manage_options', 'profile-builder-admin-bar-settings', 'wppb_show_hide_admin_bar_content' );
}
add_action( 'admin_menu', 'wppb_show_hide_admin_bar_submenu_page', 4 );
function wppb_generate_admin_bar_default_values( $roles ){
$wppb_display_admin_settings = get_option( 'wppb_display_admin_settings', 'not_found' );
if ( $wppb_display_admin_settings == 'not_found' ){
if( !empty( $roles ) ){
$admin_settings = array();
foreach ( $roles as $role ){
if( !empty( $role['name'] ) )
$admin_settings[$role['name']] = 'default';
}
update_option( 'wppb_display_admin_settings', $admin_settings );
}
}
}
/**
* Function that adds content to the "Show/Hide the Admin Bar on the Front-End" submenu page
*
* @since v.2.0
*
* @return string
*/
function wppb_show_hide_admin_bar_content() {
global $wp_roles;
wppb_generate_admin_bar_default_values( $wp_roles );
?>
<div class="wrap wppb-wrap wppb-admin-bar">
<h2><?php _e( 'Admin Bar Settings', 'profile-builder' );?></h2>
<p><?php _e( 'Choose which user roles view the admin bar in the front-end of the website.', 'profile-builder' ); ?>
<form method="post" action="options.php#show-hide-admin-bar">
<?php
$admin_bar_settings = get_option( 'wppb_display_admin_settings' );
settings_fields( 'wppb_display_admin_settings' );
?>
<table class="widefat">
<thead>
<tr>
<th class="row-title" scope="col"><?php _e('User-Role', 'profile-builder');?></th>
<th scope="col"><?php _e('Visibility', 'profile-builder');?></th>
</tr>
</thead>
<tbody>
<?php
$alt_i = 0;
foreach ( $wp_roles->roles as $role ) {
$alt_i++;
$key = $role['name'];
$setting_exists = !empty( $admin_bar_settings[$key] );
$alt_class = ( ( $alt_i%2 == 0 ) ? ' class="alternate"' : '' );
echo'<tr'.$alt_class.'>
<td>'.translate_user_role($key).'</td>
<td>
<span><input id="rd'.$key.'" type="radio" name="wppb_display_admin_settings['.$key.']" value="default"'.( ( !$setting_exists || $admin_bar_settings[$key] == 'default' ) ? ' checked' : '' ).'/><label for="rd'.$key.'">'.__( 'Default', 'profile-builder' ).'</label></span>
<span><input id="rs'.$key.'" type="radio" name="wppb_display_admin_settings['.$key.']" value="show"'.( ( $setting_exists && $admin_bar_settings[$key] == 'show') ? ' checked' : '' ).'/><label for="rs'.$key.'">'.__( 'Show', 'profile-builder' ).'</label></span>
<span><input id="rh'.$key.'" type="radio" name="wppb_display_admin_settings['.$key.']" value="hide"'.( ( $setting_exists && $admin_bar_settings[$key] == 'hide') ? ' checked' : '' ).'/><label for="rh'.$key.'">'.__( 'Hide', 'profile-builder' ).'</label></span>
</td>
</tr>';
}
?>
</table>
<div id="wppb_submit_button_div">
<input type="hidden" name="action" value="update" />
<p class="submit">
<input type="submit" class="button-primary" value="<?php _e( 'Save Changes' ) ?>" />
</p>
</div>
</form>
</div>
<?php
}
/**
* Function that changes the username on the top right menu (admin bar)
*
* @since v.2.0
*
* @return string
*/
function wppb_replace_username_on_admin_bar( $wp_admin_bar ) {
$wppb_general_settings = get_option( 'wppb_general_settings' );
if ( isset( $wppb_general_settings['loginWith'] ) && ( $wppb_general_settings['loginWith'] == 'email' ) ){
$current_user = wp_get_current_user();
if ( $current_user->ID != 0 ) {
$my_account_main = $wp_admin_bar->get_node('my-account');
$new_title1 = str_replace($current_user->display_name, $current_user->user_email, $my_account_main->title);
$wp_admin_bar->add_node(array('id' => 'my-account', 'title' => $new_title1));
$my_account_sub = $wp_admin_bar->get_node('user-info');
$wp_admin_bar->add_node(array('parent' => 'user-actions', 'id' => 'user-info', 'title' => get_avatar($current_user->ID, 64) . "<span class='display-name'>{$current_user->user_email}</span>", 'href' => get_edit_profile_url($current_user->ID), 'meta' => array('tabindex' => -1)));
}
}
return $wp_admin_bar;
}
add_filter( 'admin_bar_menu', 'wppb_replace_username_on_admin_bar', 25 );

View File

@ -1,209 +1,209 @@
<?php
/**
* Function which returns the same field-format over and over again.
*
* @since v.2.0
*
* @param string $field
* @param string $field_title
*
* @return string
*/
function wppb_field_format ( $field_title, $field ){
return trim( $field_title ).' ( '.trim( $field ).' )';
}
/**
* Add a notification for either the Username or the Email field letting the user know that, even though it is there, it won't do anything
*
* @since v.2.0
*
* @param string $form
* @param integer $id
* @param string $value
*
* @return string $form
*/
function wppb_manage_fields_display_field_title_slug( $form ){
// add a notice to fields
global $wppb_results_field;
switch ($wppb_results_field){
case 'Default - Username':
$wppb_generalSettings = get_option( 'wppb_general_settings', 'not_found' );
if ( $wppb_generalSettings != 'not_found' && $wppb_generalSettings['loginWith'] == 'email' ) {
$form .= '<div id="wppb-login-email-nag" class="wppb-backend-notice">' . sprintf(__('Login is set to be done using the E-mail. This field will NOT appear in the front-end! ( you can change these settings under the "%s" tab )', 'profile-builder'), '<a href="' . admin_url('admin.php?page=profile-builder-general-settings') . '" target="_blank">' . __('General Settings', 'profile-builder') . '</a>') . '</div>';
}
break;
case 'Default - Display name publicly as':
$form .= '<div id="wppb-display-name-nag" class="wppb-backend-notice">' . __( 'Display name publicly as - only appears on the Edit Profile page!', 'profile-builder' ) . '</div>';
break;
case 'Default - Blog Details':
$form .= '<div id="wppb-blog-details-nag" class="wppb-backend-notice">' . __( 'Blog Details - only appears on the Registration page!', 'profile-builder' ) . '</div>';
break;
}
return $form;
}
add_filter( 'wck_after_content_element', 'wppb_manage_fields_display_field_title_slug' );
/**
* Check if field type is 'Default - Display name publicly as' so we can add a notification for it
*
* @since v.2.2
*
* @param string $wck_element_class
* @param string $meta
* @param array $results
* @param integer $element_id
*
*/
function wppb_manage_fields_display_name_notice( $wck_element_class, $meta, $results, $element_id ) {
global $wppb_results_field;
$wppb_results_field = $results[$element_id]['field'];
}
add_filter( 'wck_element_class_wppb_manage_fields', 'wppb_manage_fields_display_name_notice', 10, 4 );
/**
* Function that adds a custom class to the existing container
*
* @since v.2.0
*
* @param string $update_container_class - the new class name
* @param string $meta - the name of the meta
* @param array $results
* @param integer $element_id - the ID of the element
*
* @return string
*/
function wppb_update_container_class( $update_container_class, $meta, $results, $element_id ) {
$wppb_element_type = Wordpress_Creation_Kit_PB::wck_generate_slug( $results[$element_id]["field"] );
return "class='wck_update_container update_container_$meta update_container_$wppb_element_type element_type_$wppb_element_type'";
}
add_filter( 'wck_update_container_class_wppb_manage_fields', 'wppb_update_container_class', 10, 4 );
/**
* Function that adds a custom class to the existing element
*
* @since v.2.0
*
* @param string $element_class - the new class name
* @param string $meta - the name of the meta
* @param array $results
* @param integer $element_id - the ID of the element
*
* @return string
*/
function wppb_element_class( $element_class, $meta, $results, $element_id ){
$wppb_element_type = Wordpress_Creation_Kit_PB::wck_generate_slug( $results[$element_id]["field"] );
return "class='element_type_$wppb_element_type added_fields_list'";
}
add_filter( 'wck_element_class_wppb_manage_fields', 'wppb_element_class', 10, 4 );
/**
* Functions to check password length and strength
*
* @since v.2.0
*/
/* on add user and update profile from WP admin area */
add_action( 'user_profile_update_errors', 'wppb_password_check_on_profile_update', 0, 3 );
function wppb_password_check_on_profile_update( $errors, $update, $user ){
wppb_password_check_extra_conditions( $errors, $user );
}
/* on reset password */
add_action( 'validate_password_reset', 'wppb_password_check_extra_conditions', 10, 2 );
function wppb_password_check_extra_conditions( $errors, $user ){
$password = ( isset( $_POST[ 'pass1' ] ) && trim( $_POST[ 'pass1' ] ) ) ? $_POST[ 'pass1' ] : false;
if( $password ){
$wppb_generalSettings = get_option( 'wppb_general_settings' );
if( !empty( $wppb_generalSettings['minimum_password_length'] ) ){
if( strlen( $password ) < $wppb_generalSettings['minimum_password_length'] )
$errors->add( 'pass', sprintf( __( '<strong>ERROR</strong>: The password must have the minimum length of %s characters', 'profile-builder' ), $wppb_generalSettings['minimum_password_length'] ) );
}
if( isset( $_POST['wppb_password_strength'] ) && !empty( $wppb_generalSettings['minimum_password_strength'] ) ){
$password_strength_array = array( 'short' => 0, 'bad' => 1, 'good' => 2, 'strong' => 3 );
$password_strength_text = array( 'short' => __( 'Very weak', 'profile-builder' ), 'bad' => __( 'Weak', 'profile-builder' ), 'good' => __( 'Medium', 'profile-builder' ), 'strong' => __( 'Strong', 'profile-builder' ) );
foreach( $password_strength_text as $psr_key => $psr_text ){
if( $psr_text == sanitize_text_field( $_POST['wppb_password_strength'] ) ){
$password_strength_result_slug = $psr_key;
break;
}
}
if( !empty( $password_strength_result_slug ) ){
if( $password_strength_array[$password_strength_result_slug] < $password_strength_array[$wppb_generalSettings['minimum_password_strength']] )
$errors->add( 'pass', sprintf( __( '<strong>ERROR</strong>: The password must have a minimum strength of %s', 'profile-builder' ), $password_strength_text[$wppb_generalSettings['minimum_password_strength']] ) );
}
}
}
return $errors;
}
/* we need to create a hidden field that contains the results of the password strength from the js strength tester */
add_action( 'admin_footer', 'wppb_add_hidden_password_strength_on_backend' );
add_action( 'login_footer', 'wppb_add_hidden_password_strength_on_backend' );
function wppb_add_hidden_password_strength_on_backend(){
if( $GLOBALS['pagenow'] == 'profile.php' || $GLOBALS['pagenow'] == 'user-new.php' || ( $GLOBALS['pagenow'] == 'wp-login.php' && isset( $_GET['action'] ) && ( $_GET['action'] == 'rp' || $_GET['action'] == 'resetpass' ) ) ){
$wppb_generalSettings = get_option( 'wppb_general_settings' );
if( !empty( $wppb_generalSettings['minimum_password_strength'] ) ){
?>
<script type="text/javascript">
jQuery( document ).ready( function() {
var passswordStrengthResult = jQuery( '#pass-strength-result' );
// Check for password strength meter
if ( passswordStrengthResult.length ) {
// Attach submit event to form
passswordStrengthResult.parents( 'form' ).on( 'submit', function() {
// Store check results in hidden field
jQuery( this ).append( '<input type="hidden" name="wppb_password_strength" value="' + passswordStrengthResult.text() + '">' );
});
}
});
</script>
<?php
}
}
}
/* Modify the Add Entry buttons for WCK metaboxes according to context */
add_filter( 'wck_add_entry_button', 'wppb_change_add_entry_button', 10, 2 );
function wppb_change_add_entry_button( $string, $meta ){
if( $meta == 'wppb_manage_fields' || $meta == 'wppb_epf_fields' || $meta == 'wppb_rf_fields' ){
return __( "Add Field", 'profile-builder' );
}elseif( $meta == 'wppb_epf_page_settings' || $meta == 'wppb_rf_page_settings' || $meta == 'wppb_ul_page_settings' ){
return __( "Save Settings", 'profile-builder' );
}
return $string;
}
/* Add admin footer text for encouraging users to leave a review of the plugin on wordpress.org */
function wppb_admin_rate_us( $footer_text ) {
global $current_screen;
if ($current_screen->parent_base == 'profile-builder'){
$rate_text = sprintf( __( 'If you enjoy using <strong> %1$s </strong> please <a href="%2$s" target="_blank">rate us on WordPress.org</a>. More happy users means more features, less bugs and better support for everyone. ', 'profile-builder' ),
PROFILE_BUILDER,
'https://wordpress.org/support/view/plugin-reviews/profile-builder?filter=5#postform'
);
return '<span id="footer-thankyou">' .$rate_text . '</span>';
} else {
return $footer_text;
}
}
<?php
/**
* Function which returns the same field-format over and over again.
*
* @since v.2.0
*
* @param string $field
* @param string $field_title
*
* @return string
*/
function wppb_field_format ( $field_title, $field ){
return trim( $field_title ).' ( '.trim( $field ).' )';
}
/**
* Add a notification for either the Username or the Email field letting the user know that, even though it is there, it won't do anything
*
* @since v.2.0
*
* @param string $form
* @param integer $id
* @param string $value
*
* @return string $form
*/
function wppb_manage_fields_display_field_title_slug( $form ){
// add a notice to fields
global $wppb_results_field;
switch ($wppb_results_field){
case 'Default - Username':
$wppb_generalSettings = get_option( 'wppb_general_settings', 'not_found' );
if ( $wppb_generalSettings != 'not_found' && $wppb_generalSettings['loginWith'] == 'email' ) {
$form .= '<div id="wppb-login-email-nag" class="wppb-backend-notice">' . sprintf(__('Login is set to be done using the E-mail. This field will NOT appear in the front-end! ( you can change these settings under the "%s" tab )', 'profile-builder'), '<a href="' . admin_url('admin.php?page=profile-builder-general-settings') . '" target="_blank">' . __('General Settings', 'profile-builder') . '</a>') . '</div>';
}
break;
case 'Default - Display name publicly as':
$form .= '<div id="wppb-display-name-nag" class="wppb-backend-notice">' . __( 'Display name publicly as - only appears on the Edit Profile page!', 'profile-builder' ) . '</div>';
break;
case 'Default - Blog Details':
$form .= '<div id="wppb-blog-details-nag" class="wppb-backend-notice">' . __( 'Blog Details - only appears on the Registration page!', 'profile-builder' ) . '</div>';
break;
}
return $form;
}
add_filter( 'wck_after_content_element', 'wppb_manage_fields_display_field_title_slug' );
/**
* Check if field type is 'Default - Display name publicly as' so we can add a notification for it
*
* @since v.2.2
*
* @param string $wck_element_class
* @param string $meta
* @param array $results
* @param integer $element_id
*
*/
function wppb_manage_fields_display_name_notice( $wck_element_class, $meta, $results, $element_id ) {
global $wppb_results_field;
$wppb_results_field = $results[$element_id]['field'];
}
add_filter( 'wck_element_class_wppb_manage_fields', 'wppb_manage_fields_display_name_notice', 10, 4 );
/**
* Function that adds a custom class to the existing container
*
* @since v.2.0
*
* @param string $update_container_class - the new class name
* @param string $meta - the name of the meta
* @param array $results
* @param integer $element_id - the ID of the element
*
* @return string
*/
function wppb_update_container_class( $update_container_class, $meta, $results, $element_id ) {
$wppb_element_type = Wordpress_Creation_Kit_PB::wck_generate_slug( $results[$element_id]["field"] );
return "class='wck_update_container update_container_$meta update_container_$wppb_element_type element_type_$wppb_element_type'";
}
add_filter( 'wck_update_container_class_wppb_manage_fields', 'wppb_update_container_class', 10, 4 );
/**
* Function that adds a custom class to the existing element
*
* @since v.2.0
*
* @param string $element_class - the new class name
* @param string $meta - the name of the meta
* @param array $results
* @param integer $element_id - the ID of the element
*
* @return string
*/
function wppb_element_class( $element_class, $meta, $results, $element_id ){
$wppb_element_type = Wordpress_Creation_Kit_PB::wck_generate_slug( $results[$element_id]["field"] );
return "class='element_type_$wppb_element_type added_fields_list'";
}
add_filter( 'wck_element_class_wppb_manage_fields', 'wppb_element_class', 10, 4 );
/**
* Functions to check password length and strength
*
* @since v.2.0
*/
/* on add user and update profile from WP admin area */
add_action( 'user_profile_update_errors', 'wppb_password_check_on_profile_update', 0, 3 );
function wppb_password_check_on_profile_update( $errors, $update, $user ){
wppb_password_check_extra_conditions( $errors, $user );
}
/* on reset password */
add_action( 'validate_password_reset', 'wppb_password_check_extra_conditions', 10, 2 );
function wppb_password_check_extra_conditions( $errors, $user ){
$password = ( isset( $_POST[ 'pass1' ] ) && trim( $_POST[ 'pass1' ] ) ) ? $_POST[ 'pass1' ] : false;
if( $password ){
$wppb_generalSettings = get_option( 'wppb_general_settings' );
if( !empty( $wppb_generalSettings['minimum_password_length'] ) ){
if( strlen( $password ) < $wppb_generalSettings['minimum_password_length'] )
$errors->add( 'pass', sprintf( __( '<strong>ERROR</strong>: The password must have the minimum length of %s characters', 'profile-builder' ), $wppb_generalSettings['minimum_password_length'] ) );
}
if( isset( $_POST['wppb_password_strength'] ) && !empty( $wppb_generalSettings['minimum_password_strength'] ) ){
$password_strength_array = array( 'short' => 0, 'bad' => 1, 'good' => 2, 'strong' => 3 );
$password_strength_text = array( 'short' => __( 'Very weak', 'profile-builder' ), 'bad' => __( 'Weak', 'profile-builder' ), 'good' => __( 'Medium', 'profile-builder' ), 'strong' => __( 'Strong', 'profile-builder' ) );
foreach( $password_strength_text as $psr_key => $psr_text ){
if( $psr_text == sanitize_text_field( $_POST['wppb_password_strength'] ) ){
$password_strength_result_slug = $psr_key;
break;
}
}
if( !empty( $password_strength_result_slug ) ){
if( $password_strength_array[$password_strength_result_slug] < $password_strength_array[$wppb_generalSettings['minimum_password_strength']] )
$errors->add( 'pass', sprintf( __( '<strong>ERROR</strong>: The password must have a minimum strength of %s', 'profile-builder' ), $password_strength_text[$wppb_generalSettings['minimum_password_strength']] ) );
}
}
}
return $errors;
}
/* we need to create a hidden field that contains the results of the password strength from the js strength tester */
add_action( 'admin_footer', 'wppb_add_hidden_password_strength_on_backend' );
add_action( 'login_footer', 'wppb_add_hidden_password_strength_on_backend' );
function wppb_add_hidden_password_strength_on_backend(){
if( $GLOBALS['pagenow'] == 'profile.php' || $GLOBALS['pagenow'] == 'user-new.php' || ( $GLOBALS['pagenow'] == 'wp-login.php' && isset( $_GET['action'] ) && ( $_GET['action'] == 'rp' || $_GET['action'] == 'resetpass' ) ) ){
$wppb_generalSettings = get_option( 'wppb_general_settings' );
if( !empty( $wppb_generalSettings['minimum_password_strength'] ) ){
?>
<script type="text/javascript">
jQuery( document ).ready( function() {
var passswordStrengthResult = jQuery( '#pass-strength-result' );
// Check for password strength meter
if ( passswordStrengthResult.length ) {
// Attach submit event to form
passswordStrengthResult.parents( 'form' ).on( 'submit', function() {
// Store check results in hidden field
jQuery( this ).append( '<input type="hidden" name="wppb_password_strength" value="' + passswordStrengthResult.text() + '">' );
});
}
});
</script>
<?php
}
}
}
/* Modify the Add Entry buttons for WCK metaboxes according to context */
add_filter( 'wck_add_entry_button', 'wppb_change_add_entry_button', 10, 2 );
function wppb_change_add_entry_button( $string, $meta ){
if( $meta == 'wppb_manage_fields' || $meta == 'wppb_epf_fields' || $meta == 'wppb_rf_fields' ){
return __( "Add Field", 'profile-builder' );
}elseif( $meta == 'wppb_epf_page_settings' || $meta == 'wppb_rf_page_settings' || $meta == 'wppb_ul_page_settings' ){
return __( "Save Settings", 'profile-builder' );
}
return $string;
}
/* Add admin footer text for encouraging users to leave a review of the plugin on wordpress.org */
function wppb_admin_rate_us( $footer_text ) {
global $current_screen;
if ($current_screen->parent_base == 'profile-builder'){
$rate_text = sprintf( __( 'If you enjoy using <strong> %1$s </strong> please <a href="%2$s" target="_blank">rate us on WordPress.org</a>. More happy users means more features, less bugs and better support for everyone. ', 'profile-builder' ),
PROFILE_BUILDER,
'https://wordpress.org/support/view/plugin-reviews/profile-builder?filter=5#postform'
);
return '<span id="footer-thankyou">' .$rate_text . '</span>';
} else {
return $footer_text;
}
}
add_filter('admin_footer_text','wppb_admin_rate_us');

View File

@ -1,194 +1,195 @@
<?php
/**
* Function that creates the "Basic Information" submenu page
*
* @since v.2.0
*
* @return void
*/
function wppb_register_basic_info_submenu_page() {
add_submenu_page( 'profile-builder', __( 'Basic Information', 'profile-builder' ), __( 'Basic Information', 'profile-builder' ), 'manage_options', 'profile-builder-basic-info', 'wppb_basic_info_content' );
}
add_action( 'admin_menu', 'wppb_register_basic_info_submenu_page', 2 );
/**
* Function that adds content to the "Basic Information" submenu page
*
* @since v.2.0
*
* @return string
*/
function wppb_basic_info_content() {
$version = 'Free';
//$version = ( ( PROFILE_BUILDER == 'Profile Builder Pro' ) ? 'Pro' : $version );
//$version = ( ( PROFILE_BUILDER == 'Profile Builder Hobbyist' ) ? 'Hobbyist' : $version );
?>
<div class="wrap wppb-wrap wppb-info-wrap">
<div class="wppb-badge <?php echo $version; ?>"><span><?php printf( __( 'Version %s' ), PROFILE_BUILDER_VERSION ); ?></span></div>
<h1><?php echo __( '<strong>Profile Builder </strong>' . $version, 'profile-builder' ); ?></h1>
<p class="wppb-info-text"><?php printf( __( 'The best way to add front-end registration, edit profile and login forms.', 'profile-builder' ) ); ?></p>
<hr />
<h2 class="wppb-callout"><?php _e( 'For Modern User Interaction', 'profile-builder' ); ?></h2>
<div class="wppb-row wppb-3-col">
<div>
<h3><?php _e( 'Login', 'profile-builder' ); ?></h3>
<p><?php printf( __( 'Friction-less login using %s shortcode or a widget.', 'profile-builder' ), '<strong class="nowrap">[wppb-login]</strong>' ); ?></p>
</div>
<div>
<h3><?php _e( 'Registration', 'profile-builder' ); ?></h3>
<p><?php printf( __( 'Beautiful registration forms fully customizable using the %s shortcode.', 'profile-builder' ), '<strong class="nowrap">[wppb-register]</strong>' ); ?></p>
</div>
<div>
<h3><?php _e( 'Edit Profile', 'profile-builder' ); ?></h3>
<p><?php printf( __( 'Straight forward edit profile forms using %s shortcode.', 'profile-builder' ), '<strong class="nowrap">[wppb-edit-profile]</strong>' ); ?></p>
</div>
</div>
<?php ob_start(); /*?>
<hr/>
<div>
<h3><?php _e( 'Extra Features', 'profile-builder' );?></h3>
<p><?php _e( 'Features that give you more control over your users, increased security and help you fight user registration spam.', 'profile-builder' ); ?></p>
<p><a href="admin.php?page=profile-builder-general-settings" class="button"><?php _e( 'Enable extra features', 'profile-builder' ); ?></a></p>
</div>
<div class="wppb-row wppb-3-col">
<div>
<h3><?php _e( 'Recover Password', 'profile-builder' ); ?></h3>
<p><?php printf( __( 'Allow users to recover their password in the front-end using the %s.', 'profile-builder' ), '<strong class="nowrap">[wppb-recover-password]</strong>' ); ?></p>
</div>
<div>
<h3><?php _e( 'Admin Approval (*)', 'profile-builder' ); ?></h3>
<p><?php _e( 'You decide who is a user on your website. Get notified via email or approve multiple users at once from the WordPress UI.', 'profile-builder' ); ?></p>
</div>
<div>
<h3><?php _e( 'Email Confirmation', 'profile-builder' ); ?></h3>
<p><?php _e( 'Make sure users sign up with genuine emails. On registration users will receive a notification to confirm their email address.', 'profile-builder' ); ?></p>
</div>
<div>
<h3><?php _e( 'Minimum Password Length and Strength Meter', 'profile-builder' ); ?></h3>
<p><?php _e( 'Eliminate weak passwords altogether by setting a minimum password length and enforcing a certain password strength.', 'profile-builder' ); ?></p>
</div>
<div>
<h3><?php _e( 'Login with Email or Username', 'profile-builder' ); ?></h3>
<p><?php _e( 'Allow users to log in with their email or username when accessing your site.', 'profile-builder' ); ?></p>
</div>
</div>
<?php
// Output here the Extra Features html for the Free version
$extra_features_html = ob_get_contents();
ob_end_clean();
if ( $version == 'Free' ) echo $extra_features_html; ?>
<hr/>
<div class="wppb-row wppb-2-col">
<div>
<h3><?php _e( 'Customize Your Forms The Way You Want (*)', 'profile-builder' ); ?></h3>
<p><?php _e( 'With Extra Profile Fields you can create the exact registration form your project needs.', 'profile-builder' ); ?></p>
<?php if ($version == 'Free'){ ?>
<p><a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wpbackend&utm_medium=clientsite&utm_content=basicinfo-extrafields&utm_campaign=PBFree" class="wppb-button-free"><?php _e( 'Extra Profile Fields are available in Hobbyist or PRO versions', 'profile-builder' ); ?></a></p>
<?php } else {?>
<p><a href="admin.php?page=manage-fields" class="button"><?php _e( 'Get started with extra fields', 'profile-builder' ); ?></a></p>
<?php } ?>
<ul style="float: left; margin-right: 50px;">
<li><?php _e( 'Avatar Upload', 'profile-builder' ); ?></li>
<li><?php _e( 'Generic Uploads', 'profile-builder' ); ?></li>
<li><?php _e( 'Agree To Terms Checkbox', 'profile-builder' ); ?></li>
<li><?php _e( 'Datepicker', 'profile-builder' ); ?> </li>
<li><?php _e( 'Timepicker', 'profile-builder' ); ?> </li>
<li><?php _e( 'Colorpicker', 'profile-builder' ); ?> </li>
<li><?php _e( 'reCAPTCHA', 'profile-builder' ); ?></li>
<li><?php _e( 'Country Select', 'profile-builder' ); ?></li>
<li><?php _e( 'Currency Select', 'profile-builder' ); ?></li>
<li><?php _e( 'Timezone Select', 'profile-builder' ); ?></li>
</ul>
<ul style="float: left;">
<li><?php _e( 'Input / Hidden Input', 'profile-builder' ); ?></li>
<li><?php _e( 'Number', 'profile-builder' ); ?></li>
<li><?php _e( 'Checkbox', 'profile-builder' ); ?></li>
<li><?php _e( 'Select', 'profile-builder' ); ?></li>
<li><?php _e( 'Radio Buttons', 'profile-builder' ); ?></li>
<li><?php _e( 'Textarea', 'profile-builder' ); ?></li>
<li><?php _e( 'Validation', 'profile-builder' ); ?></li>
<li><?php _e( 'Map', 'profile-builder' ); ?></li>
<li><?php _e( 'HTML', 'profile-builder' ); ?></li>
</ul>
</div>
<div>
<img src="<?php echo WPPB_PLUGIN_URL; ?>assets/images/pb_fields.png" alt="Profile Builder Extra Fields" class="wppb-fields-image" />
</div>
</div>
<hr/>
<div>
<h3><?php _e( 'Powerful Modules (**)', 'profile-builder' );?></h3>
<p><?php _e( 'Everything you will need to manage your users is probably already available using the Pro Modules.', 'profile-builder' ); ?></p>
<?php if( file_exists ( WPPB_PLUGIN_DIR.'/modules/modules.php' ) ): ?>
<p><a href="admin.php?page=profile-builder-modules" class="button"><?php _e( 'Enable your modules', 'profile-builder' ); ?></a></p>
<?php endif; ?>
<?php if ($version == 'Free'){ ?>
<p><a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wpbackend&utm_medium=clientsite&utm_content=basicinfo-modules&utm_campaign=PBFree" class="wppb-button-free"><?php _e( 'Find out more about PRO Modules', 'profile-builder' ); ?></a></p>
<?php }?>
</div>
<div class="wppb-row wppb-3-col">
<div>
<h3><?php _e( 'User Listing', 'profile-builder' ); ?></h3>
<?php if ($version == 'Free'): ?>
<p><?php _e( 'Easy to edit templates for listing your website users as well as creating single user pages. Shortcode based, offering many options to customize your listings.', 'profile-builder' ); ?></p>
<?php else : ?>
<p><?php printf( __( 'To create a page containing the users registered to this current site/blog, insert the following shortcode in a page of your chosing: %s.', 'profile-builder' ), '<strong class="nowrap">[wppb-list-users]</strong>' ); ?></p>
<?php endif;?>
</div>
<div>
<h3><?php _e( 'Email Customizer', 'profile-builder' ); ?></h3>
<p><?php _e( 'Personalize all emails sent to your users or admins. On registration, email confirmation, admin approval / un-approval.', 'profile-builder' ); ?></p>
</div>
<div>
<h3><?php _e( 'Custom Redirects', 'profile-builder' ); ?></h3>
<p><?php _e( 'Keep your users out of the WordPress dashboard, redirect them to the front-page after login or registration, everything is just a few clicks away.', 'profile-builder' ); ?></p>
</div>
</div>
<div class="wppb-row wppb-3-col">
<div>
<h3><?php _e( 'Multiple Registration Forms', 'profile-builder' ); ?></h3>
<p><?php _e( 'Set up multiple registration forms with different fields for certain user roles. Capture different information from different types of users.', 'profile-builder' ); ?></p>
</div>
<div>
<h3><?php _e( 'Multiple Edit-profile Forms', 'profile-builder' ); ?></h3>
<p><?php _e( 'Allow different user roles to edit their specific information. Set up multiple edit-profile forms with different fields for certain user roles.', 'profile-builder' ); ?></p>
</div>
<div>
<h3><?php _e( 'Repeater Fields', 'profile-builder' ); ?></h3>
<p><?php _e( 'Set up a repeating group of fields on register and edit profile forms. Limit the number of repeated groups for each user role.', 'profile-builder' ); ?></p>
</div>
</div>
<?php
//Output here Extra Features html for Hobbyist or Pro versions
if ( $version != 'Free' ) echo $extra_features_html; ?>
<hr/>
<div class="wrap wppb-wrap wppb-1-3-col">
<div>
<a href="<?php echo admin_url('options.php?page=profile-builder-pms-promo'); ?>"><img src="<?php echo plugins_url( '../assets/images/pb-pms-cross-promotion.png', __FILE__ ); ?>" alt="paid member subscriptions"/></a>
</div>
<div>
<h3>Paid user profiles with Profile Builder and Paid Member Subscriptions</h3>
<p>One of the most requested features in Profile Builder was for users to be able to pay for an account.</p>
<p>Now that's possible using the free WordPress plugin - <a href="<?php echo admin_url('options.php?page=profile-builder-pms-promo'); ?>">Paid Member Subscriptions</a>.</p>
<p><a href="<?php echo admin_url('options.php?page=profile-builder-pms-promo'); ?>" class="button">Find out how</a></p>
</div>
</div>
<hr/>
<div>
<h3>Extra Notes</h3>
<ul>
<li><?php printf( __( ' * only available in the %1$sHobbyist and Pro versions%2$s.', 'profile-builder' ) ,'<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wpbackend&utm_medium=clientsite&utm_content=basicinfo-extranotes&utm_campaign=PB'.$version.'" target="_blank">', '</a>' );?></li>
<li><?php printf( __( '** only available in the %1$sPro version%2$s.', 'profile-builder' ), '<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wpbackend&utm_medium=clientsite&utm_content=basicinfo-extranotes&utm_campaign=PB'.$version.'" target="_blank">', '</a>' );?></li>
</ul>
</div>
</div>
<?php*/
}
<?php
/**
* Function that creates the "Basic Information" submenu page
*
* @since v.2.0
*
* @return void
*/
function wppb_register_basic_info_submenu_page() {
add_submenu_page( 'profile-builder', __( 'Basic Information', 'profile-builder' ), __( 'Basic Information', 'profile-builder' ), 'manage_options', 'profile-builder-basic-info', 'wppb_basic_info_content' );
}
add_action( 'admin_menu', 'wppb_register_basic_info_submenu_page', 2 );
/**
* Function that adds content to the "Basic Information" submenu page
*
* @since v.2.0
*
* @return string
*/
function wppb_basic_info_content() {
$version = 'Free';
$version = ( ( PROFILE_BUILDER == 'Profile Builder Pro' ) ? 'Pro' : $version );
$version = ( ( PROFILE_BUILDER == 'Profile Builder Hobbyist' ) ? 'Hobbyist' : $version );
?>
<div class="wrap wppb-wrap wppb-info-wrap">
<div class="wppb-badge <?php echo $version; ?>"><span><?php printf( __( 'Version %s' ), PROFILE_BUILDER_VERSION ); ?></span></div>
<h1><?php echo __( '<strong>Profile Builder </strong>' . $version, 'profile-builder' ); ?></h1>
<p class="wppb-info-text"><?php printf( __( 'The best way to add front-end registration, edit profile and login forms.', 'profile-builder' ) ); ?></p>
<hr />
<h2 class="wppb-callout"><?php _e( 'For Modern User Interaction', 'profile-builder' ); ?></h2>
<div class="wppb-row wppb-3-col">
<div>
<h3><?php _e( 'Login', 'profile-builder' ); ?></h3>
<p><?php printf( __( 'Friction-less login using %s shortcode or a widget.', 'profile-builder' ), '<strong class="nowrap">[wppb-login]</strong>' ); ?></p>
</div>
<div>
<h3><?php _e( 'Registration', 'profile-builder' ); ?></h3>
<p><?php printf( __( 'Beautiful registration forms fully customizable using the %s shortcode.', 'profile-builder' ), '<strong class="nowrap">[wppb-register]</strong>' ); ?></p>
</div>
<div>
<h3><?php _e( 'Edit Profile', 'profile-builder' ); ?></h3>
<p><?php printf( __( 'Straight forward edit profile forms using %s shortcode.', 'profile-builder' ), '<strong class="nowrap">[wppb-edit-profile]</strong>' ); ?></p>
</div>
</div>
<?php ob_start(); /*?>
<hr/>
<div>
<h3><?php _e( 'Extra Features', 'profile-builder' );?></h3>
<p><?php _e( 'Features that give you more control over your users, increased security and help you fight user registration spam.', 'profile-builder' ); ?></p>
<p><a href="admin.php?page=profile-builder-general-settings" class="button"><?php _e( 'Enable extra features', 'profile-builder' ); ?></a></p>
</div>
<div class="wppb-row wppb-3-col">
<div>
<h3><?php _e( 'Recover Password', 'profile-builder' ); ?></h3>
<p><?php printf( __( 'Allow users to recover their password in the front-end using the %s.', 'profile-builder' ), '<strong class="nowrap">[wppb-recover-password]</strong>' ); ?></p>
</div>
<div>
<h3><?php _e( 'Admin Approval (*)', 'profile-builder' ); ?></h3>
<p><?php _e( 'You decide who is a user on your website. Get notified via email or approve multiple users at once from the WordPress UI.', 'profile-builder' ); ?></p>
</div>
<div>
<h3><?php _e( 'Email Confirmation', 'profile-builder' ); ?></h3>
<p><?php _e( 'Make sure users sign up with genuine emails. On registration users will receive a notification to confirm their email address.', 'profile-builder' ); ?></p>
</div>
<div>
<h3><?php _e( 'Minimum Password Length and Strength Meter', 'profile-builder' ); ?></h3>
<p><?php _e( 'Eliminate weak passwords altogether by setting a minimum password length and enforcing a certain password strength.', 'profile-builder' ); ?></p>
</div>
<div>
<h3><?php _e( 'Login with Email or Username', 'profile-builder' ); ?></h3>
<p><?php _e( 'Allow users to log in with their email or username when accessing your site.', 'profile-builder' ); ?></p>
</div>
</div>
<?php
// Output here the Extra Features html for the Free version
$extra_features_html = ob_get_contents();
ob_end_clean();
if ( $version == 'Free' ) echo $extra_features_html; ?>
<hr/>
<div class="wppb-row wppb-2-col">
<div>
<h3><?php _e( 'Customize Your Forms The Way You Want (*)', 'profile-builder' ); ?></h3>
<p><?php _e( 'With Extra Profile Fields you can create the exact registration form your project needs.', 'profile-builder' ); ?></p>
<?php if ($version == 'Free'){ ?>
<p><a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wpbackend&utm_medium=clientsite&utm_content=basicinfo-extrafields&utm_campaign=PBFree" class="wppb-button-free"><?php _e( 'Extra Profile Fields are available in Hobbyist or PRO versions', 'profile-builder' ); ?></a></p>
<?php } else {?>
<p><a href="admin.php?page=manage-fields" class="button"><?php _e( 'Get started with extra fields', 'profile-builder' ); ?></a></p>
<?php } ?>
<ul style="float: left; margin-right: 50px;">
<li><?php _e( 'Avatar Upload', 'profile-builder' ); ?></li>
<li><?php _e( 'Generic Uploads', 'profile-builder' ); ?></li>
<li><?php _e( 'Agree To Terms Checkbox', 'profile-builder' ); ?></li>
<li><?php _e( 'Datepicker', 'profile-builder' ); ?> </li>
<li><?php _e( 'Timepicker', 'profile-builder' ); ?> </li>
<li><?php _e( 'Colorpicker', 'profile-builder' ); ?> </li>
<li><?php _e( 'reCAPTCHA', 'profile-builder' ); ?></li>
<li><?php _e( 'Country Select', 'profile-builder' ); ?></li>
<li><?php _e( 'Currency Select', 'profile-builder' ); ?></li>
<li><?php _e( 'Timezone Select', 'profile-builder' ); ?></li>
</ul>
<ul style="float: left;">
<li><?php _e( 'Input / Hidden Input', 'profile-builder' ); ?></li>
<li><?php _e( 'Number', 'profile-builder' ); ?></li>
<li><?php _e( 'Checkbox', 'profile-builder' ); ?></li>
<li><?php _e( 'Select', 'profile-builder' ); ?></li>
<li><?php _e( 'Radio Buttons', 'profile-builder' ); ?></li>
<li><?php _e( 'Textarea', 'profile-builder' ); ?></li>
<li><?php _e( 'Validation', 'profile-builder' ); ?></li>
<li><?php _e( 'Map', 'profile-builder' ); ?></li>
<li><?php _e( 'HTML', 'profile-builder' ); ?></li>
</ul>
</div>
<div>
<img src="<?php echo WPPB_PLUGIN_URL; ?>assets/images/pb_fields.png" alt="Profile Builder Extra Fields" class="wppb-fields-image" />
</div>
</div>
<hr/>
<div>
<h3><?php _e( 'Powerful Modules (**)', 'profile-builder' );?></h3>
<p><?php _e( 'Everything you will need to manage your users is probably already available using the Pro Modules.', 'profile-builder' ); ?></p>
<?php if( file_exists ( WPPB_PLUGIN_DIR.'/modules/modules.php' ) ): ?>
<p><a href="admin.php?page=profile-builder-modules" class="button"><?php _e( 'Enable your modules', 'profile-builder' ); ?></a></p>
<?php endif; ?>
<?php if ($version == 'Free'){ ?>
<p><a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wpbackend&utm_medium=clientsite&utm_content=basicinfo-modules&utm_campaign=PBFree" class="wppb-button-free"><?php _e( 'Find out more about PRO Modules', 'profile-builder' ); ?></a></p>
<?php }?>
</div>
<div class="wppb-row wppb-3-col">
<div>
<h3><?php _e( 'User Listing', 'profile-builder' ); ?></h3>
<?php if ($version == 'Free'): ?>
<p><?php _e( 'Easy to edit templates for listing your website users as well as creating single user pages. Shortcode based, offering many options to customize your listings.', 'profile-builder' ); ?></p>
<?php else : ?>
<p><?php printf( __( 'To create a page containing the users registered to this current site/blog, insert the following shortcode in a page of your chosing: %s.', 'profile-builder' ), '<strong class="nowrap">[wppb-list-users]</strong>' ); ?></p>
<?php endif;?>
</div>
<div>
<h3><?php _e( 'Email Customizer', 'profile-builder' ); ?></h3>
<p><?php _e( 'Personalize all emails sent to your users or admins. On registration, email confirmation, admin approval / un-approval.', 'profile-builder' ); ?></p>
</div>
<div>
<h3><?php _e( 'Custom Redirects', 'profile-builder' ); ?></h3>
<p><?php _e( 'Keep your users out of the WordPress dashboard, redirect them to the front-page after login or registration, everything is just a few clicks away.', 'profile-builder' ); ?></p>
</div>
</div>
<div class="wppb-row wppb-3-col">
<div>
<h3><?php _e( 'Multiple Registration Forms', 'profile-builder' ); ?></h3>
<p><?php _e( 'Set up multiple registration forms with different fields for certain user roles. Capture different information from different types of users.', 'profile-builder' ); ?></p>
</div>
<div>
<h3><?php _e( 'Multiple Edit-profile Forms', 'profile-builder' ); ?></h3>
<p><?php _e( 'Allow different user roles to edit their specific information. Set up multiple edit-profile forms with different fields for certain user roles.', 'profile-builder' ); ?></p>
</div>
<div>
<h3><?php _e( 'Repeater Fields', 'profile-builder' ); ?></h3>
<p><?php _e( 'Set up a repeating group of fields on register and edit profile forms. Limit the number of repeated groups for each user role.', 'profile-builder' ); ?></p>
</div>
</div>
<?php
//Output here Extra Features html for Hobbyist or Pro versions
if ( $version != 'Free' ) echo $extra_features_html; ?>
<hr/>
<div class="wrap wppb-wrap wppb-1-3-col">
<div>
<a href="<?php echo admin_url('options.php?page=profile-builder-pms-promo'); ?>"><img src="<?php echo plugins_url( '../assets/images/pb-pms-cross-promotion.png', __FILE__ ); ?>" alt="paid member subscriptions"/></a>
</div>
<div>
<h3>Paid user profiles with Profile Builder and Paid Member Subscriptions</h3>
<p>One of the most requested features in Profile Builder was for users to be able to pay for an account.</p>
<p>Now that's possible using the free WordPress plugin - <a href="<?php echo admin_url('options.php?page=profile-builder-pms-promo'); ?>">Paid Member Subscriptions</a>.</p>
<p><a href="<?php echo admin_url('options.php?page=profile-builder-pms-promo'); ?>" class="button">Find out how</a></p>
</div>
</div>
<hr/>
<div>
<h3>Extra Notes</h3>
<ul>
<li><?php printf( __( ' * only available in the %1$sHobbyist and Pro versions%2$s.', 'profile-builder' ) ,'<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wpbackend&utm_medium=clientsite&utm_content=basicinfo-extranotes&utm_campaign=PB'.$version.'" target="_blank">', '</a>' );?></li>
<li><?php printf( __( '** only available in the %1$sPro version%2$s.', 'profile-builder' ), '<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wpbackend&utm_medium=clientsite&utm_content=basicinfo-extranotes&utm_campaign=PB'.$version.'" target="_blank">', '</a>' );?></li>
</ul>
</div>
</div>
<?php
*/
}

View File

@ -1,290 +1,290 @@
<?php
/**
* Function that creates the "General Settings" submenu page
*
* @since v.2.0
*
* @return void
*/
function wppb_register_general_settings_submenu_page() {
add_submenu_page( 'profile-builder', __( 'General Settings', 'profile-builder' ), __( 'General Settings', 'profile-builder' ), 'manage_options', 'profile-builder-general-settings', 'wppb_general_settings_content' );
}
add_action( 'admin_menu', 'wppb_register_general_settings_submenu_page', 3 );
function wppb_generate_default_settings_defaults(){
add_option( 'wppb_general_settings', array( 'extraFieldsLayout' => 'default', 'emailConfirmation' => 'no', 'activationLandingPage' => '', 'adminApproval' => 'no', 'loginWith' => 'usernameemail', 'rolesEditor' => 'no' ) );
}
/**
* Function that adds content to the "General Settings" submenu page
*
* @since v.2.0
*
* @return string
*/
function wppb_general_settings_content() {
wppb_generate_default_settings_defaults();
?>
<div class="wrap wppb-wrap">
<form method="post" action="options.php#general-settings">
<?php $wppb_generalSettings = get_option( 'wppb_general_settings' ); ?>
<?php settings_fields( 'wppb_general_settings' ); ?>
<h2><?php _e( 'General Settings', 'profile-builder' ); ?></h2>
<table class="form-table">
<tr>
<th scope="row">
<?php _e( "Load Profile Builder's own CSS file in the front-end:", "profile-builder" ); ?>
</th>
<td>
<label><input type="checkbox" name="wppb_general_settings[extraFieldsLayout]"<?php echo ( ( isset( $wppb_generalSettings['extraFieldsLayout'] ) && ( $wppb_generalSettings['extraFieldsLayout'] == 'default' ) ) ? ' checked' : '' ); ?> value="default" class="wppb-select"><?php _e( 'Yes', 'profile-builder' ); ?></label>
<ul>
<li class="description"><?php printf( __( 'You can find the default file here: %1$s', 'profile-builder' ), '<a href="'.dirname( plugin_dir_url( __FILE__ ) ).'/assets/css/style-front-end.css" target="_blank">'.dirname( dirname( plugin_basename( __FILE__ ) ) ).'\assets\css\style-front-end.css</a>' ); ?></li>
</ul>
</td>
</tr>
<tr>
<th scope="row">
<?php _e( '"Email Confirmation" Activated:', 'profile-builder' );?>
</th>
<td>
<select name="wppb_general_settings[emailConfirmation]" class="wppb-select" id="wppb_settings_email_confirmation" onchange="wppb_display_page_select(this.value)">
<option value="yes" <?php if ( $wppb_generalSettings['emailConfirmation'] == 'yes' ) echo 'selected'; ?>><?php _e( 'Yes', 'profile-builder' ); ?></option>
<option value="no" <?php if ( $wppb_generalSettings['emailConfirmation'] == 'no' ) echo 'selected'; ?>><?php _e( 'No', 'profile-builder' ); ?></option>
</select>
<ul>
<li class="description"><?php _e( 'This works with front-end forms only. Recommended to redirect WP default registration to a Profile Builder one using "Custom Redirects" module.', 'profile-builder' ); ?></li>
<?php if ( $wppb_generalSettings['emailConfirmation'] == 'yes' ) { ?>
<li class="description dynamic1"><?php printf( __( 'You can find a list of unconfirmed email addresses %1$sUsers > All Users > Email Confirmation%2$s.', 'profile-builder' ), '<a href="'.get_bloginfo( 'url' ).'/wp-admin/users.php?page=unconfirmed_emails">', '</a>' )?></li>
<?php } ?>
</ul>
</td>
</tr>
<tr id="wppb-settings-activation-page">
<th scope="row">
<?php _e( '"Email Confirmation" Landing Page:', 'profile-builder' ); ?>
</th>
<td>
<select name="wppb_general_settings[activationLandingPage]" class="wppb-select">
<option value="" <?php if ( empty( $wppb_generalSettings['emailConfirmation'] ) ) echo 'selected'; ?>></option>
<optgroup label="<?php _e( 'Existing Pages', 'profile-builder' ); ?>">
<?php
$pages = get_pages( apply_filters( 'wppb_page_args_filter', array( 'sort_order' => 'ASC', 'sort_column' => 'post_title', 'post_type' => 'page', 'post_status' => array( 'publish' ) ) ) );
foreach ( $pages as $key => $value ){
echo '<option value="'.$value->ID.'"';
if ( $wppb_generalSettings['activationLandingPage'] == $value->ID )
echo ' selected';
echo '>' . $value->post_title . '</option>';
}
?>
</optgroup>
</select>
<p class="description">
<?php _e( 'Specify the page where the users will be directed when confirming the email account. This page can differ from the register page(s) and can be changed at any time. If none selected, a simple confirmation page will be displayed for the user.', 'profile-builder' ); ?>
</p>
</td>
</tr>
<?php
if ( file_exists( WPPB_PLUGIN_DIR.'/features/admin-approval/admin-approval.php' ) ){
?>
<tr>
<th scope="row">
<?php _e( '"Admin Approval" Activated:', 'profile-builder' ); ?>
</th>
<td>
<select id="adminApprovalSelect" name="wppb_general_settings[adminApproval]" class="wppb-select" onchange="wppb_display_page_select_aa(this.value)">
<option value="yes" <?php if( !empty( $wppb_generalSettings['adminApproval'] ) && $wppb_generalSettings['adminApproval'] == 'yes' ) echo 'selected'; ?>><?php _e( 'Yes', 'profile-builder' ); ?></option>
<option value="no" <?php if( !empty( $wppb_generalSettings['adminApproval'] ) && $wppb_generalSettings['adminApproval'] == 'no' ) echo 'selected'; ?>><?php _e( 'No', 'profile-builder' ); ?></option>
</select>
<ul>
<li class="description dynamic2"><?php printf( __( 'You can find a list of users at %1$sUsers > All Users > Admin Approval%2$s.', 'profile-builder' ), '<a href="'.get_bloginfo( 'url' ).'/wp-admin/users.php?page=admin_approval&orderby=registered&order=desc">', '</a>' )?></li>
<ul>
</td>
</tr>
<tr class="dynamic2">
<th scope="row">
<?php _e( '"Admin Approval" on User Role:', 'profile-builder' ); ?>
</th>
<td>
<div id="wrap">
<?php
$wppb_userRoles = wppb_adminApproval_onUserRole();
if( ! empty( $wppb_userRoles ) ) {
foreach( $wppb_userRoles as $role => $role_name ) {
echo '<label><input type="checkbox" id="adminApprovalOnUserRoleCheckbox" name="wppb_general_settings[adminApprovalOnUserRole][]" class="wppb-checkboxes" value="' . esc_attr( $role ) . '"';
if( ! empty( $wppb_generalSettings['adminApprovalOnUserRole'] ) && in_array( $role, $wppb_generalSettings['adminApprovalOnUserRole'] ) ) echo ' checked';
if( empty( $wppb_generalSettings['adminApprovalOnUserRole'] ) ) echo ' checked';
echo '>';
echo $role_name . '</label><br>';
}
}
?>
</div>
<ul>
<li class="description"><?php printf( __( 'Select on what user roles to activate Admin Approval.', 'profile-builder' ) ) ?></li>
<ul>
</td>
</tr>
<?php } ?>
<?php
if( file_exists( WPPB_PLUGIN_DIR.'/features/roles-editor/roles-editor.php' ) ) {
?>
<tr>
<th scope="row">
<?php _e( '"Roles Editor" Activated:', 'profile-builder' ); ?>
</th>
<td>
<select id="rolesEditorSelect" name="wppb_general_settings[rolesEditor]" class="wppb-select" onchange="wppb_display_page_select_re(this.value)">
<option value="no" <?php if( !empty( $wppb_generalSettings['rolesEditor'] ) && $wppb_generalSettings['rolesEditor'] == 'no' ) echo 'selected'; ?>><?php _e( 'No', 'profile-builder' ); ?></option>
<option value="yes" <?php if( !empty( $wppb_generalSettings['rolesEditor'] ) && $wppb_generalSettings['rolesEditor'] == 'yes' ) echo 'selected'; ?>><?php _e( 'Yes', 'profile-builder' ); ?></option>
</select>
<ul>
<li class="description dynamic3"><?php printf( __( 'You can add / edit user roles at %1$sUsers > Roles Editor%2$s.', 'profile-builder' ), '<a href="'.get_bloginfo( 'url' ).'/wp-admin/edit.php?post_type=wppb-roles-editor">', '</a>' )?></li>
<ul>
</td>
</tr>
<?php } ?>
<?php
/*if ( PROFILE_BUILDER == 'Profile Builder Free' ) {
?>
<tr>
<th scope="row">
<?php _e( '"Admin Approval" Feature:', 'profile-builder' ); ?>
</th>
<td>
<p><em> <?php printf( __( 'You decide who is a user on your website. Get notified via email or approve multiple users at once from the WordPress UI. Enable Admin Approval by upgrading to %1$sHobbyist or PRO versions%2$s.', 'profile-builder' ),'<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wpbackend&utm_medium=clientsite&utm_content=general-settings-link&utm_campaign=PBFree">', '</a>' )?></em></p>
</td>
</tr>
<?php }*/ ?>
<tr>
<th scope="row">
<?php _e( 'Allow Users to Log in With:', 'profile-builder' ); ?>
</th>
<td>
<select name="wppb_general_settings[loginWith]" class="wppb-select">
<option value="usernameemail" <?php if ( $wppb_generalSettings['loginWith'] == 'usernameemail' ) echo 'selected'; ?>><?php _e( 'Username and Email', 'profile-builder' ); ?></option>
<option value="username" <?php if ( $wppb_generalSettings['loginWith'] == 'username' ) echo 'selected'; ?>><?php _e( 'Username', 'profile-builder' ); ?></option>
<option value="email" <?php if ( $wppb_generalSettings['loginWith'] == 'email' ) echo 'selected'; ?>><?php _e( 'Email', 'profile-builder' ); ?></option>
</select>
<ul>
<li class="description"><?php _e( '"Username and Email" - users can Log In with both Username and Email.', 'profile-builder' ); ?></li>
<li class="description"><?php _e( '"Username" - users can Log In only with Username.', 'profile-builder' ); ?></li>
<li class="description"><?php _e( '"Email" - users can Log In only with Email.', 'profile-builder' ); ?></li>
</ul>
</td>
</tr>
<tr>
<th scope="row">
<?php _e( 'Minimum Password Length:', 'profile-builder' ); ?>
</th>
<td>
<input type="text" name="wppb_general_settings[minimum_password_length]" class="wppb-text" value="<?php if( !empty( $wppb_generalSettings['minimum_password_length'] ) ) echo esc_attr( $wppb_generalSettings['minimum_password_length'] ); ?>"/>
<ul>
<li class="description"><?php _e( 'Enter the minimum characters the password should have. Leave empty for no minimum limit', 'profile-builder' ); ?> </li>
</ul>
</td>
</tr>
<tr>
<th scope="row">
<?php _e( 'Minimum Password Strength:', 'profile-builder' ); ?>
</th>
<td>
<select name="wppb_general_settings[minimum_password_strength]" class="wppb-select">
<option value=""><?php _e( 'Disabled', 'profile-builder' ); ?></option>
<option value="short" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'short' ) echo 'selected'; ?>><?php _e( 'Very weak', 'profile-builder' ); ?></option>
<option value="bad" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'bad' ) echo 'selected'; ?>><?php _e( 'Weak', 'profile-builder' ); ?></option>
<option value="good" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'good' ) echo 'selected'; ?>><?php _e( 'Medium', 'profile-builder' ); ?></option>
<option value="strong" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'strong' ) echo 'selected'; ?>><?php _e( 'Strong', 'profile-builder' ); ?></option>
</select>
</td>
</tr>
<?php do_action( 'wppb_extra_general_settings', $wppb_generalSettings ); ?>
</table>
<input type="hidden" name="action" value="update" />
<p class="submit"><input type="submit" class="button-primary" value="<?php _e( 'Save Changes' ); ?>" /></p>
</form>
</div>
<?php
}
/*
* Function that sanitizes the general settings
*
* @param array $wppb_generalSettings
*
* @since v.2.0.7
*/
function wppb_general_settings_sanitize( $wppb_generalSettings ) {
$wppb_generalSettings = apply_filters( 'wppb_general_settings_sanitize_extra', $wppb_generalSettings );
if( !empty( $wppb_generalSettings ) ){
foreach( $wppb_generalSettings as $settings_name => $settings_value ){
if( $settings_name == "minimum_password_length" || $settings_name == "activationLandingPage" )
$wppb_generalSettings[$settings_name] = filter_var( $settings_value, FILTER_SANITIZE_NUMBER_INT );
elseif( $settings_name == "extraFieldsLayout" || $settings_name == "emailConfirmation" || $settings_name == "adminApproval" || $settings_name == "loginWith" || $settings_name == "minimum_password_strength" )
$wppb_generalSettings[$settings_name] = filter_var( $settings_value, FILTER_SANITIZE_STRING );
elseif( $settings_name == "adminApprovalOnUserRole" ){
if( is_array( $settings_value ) && !empty( $settings_value ) ){
foreach( $settings_value as $key => $value ){
$wppb_generalSettings[$settings_name][$key] = filter_var( $value, FILTER_SANITIZE_STRING );
}
}
}
}
}
return $wppb_generalSettings;
}
/*
* Function that pushes settings errors to the user
*
* @since v.2.0.7
*/
function wppb_general_settings_admin_notices() {
settings_errors( 'wppb_general_settings' );
}
add_action( 'admin_notices', 'wppb_general_settings_admin_notices' );
/*
* Function that return user roles
*
* @since v.2.2.0
*
* @return array
*/
function wppb_adminApproval_onUserRole() {
global $wp_roles;
$wp_roles = new WP_Roles();
$roles = $wp_roles->get_names();
unset( $roles['administrator'] );
return $roles;
}
<?php
/**
* Function that creates the "General Settings" submenu page
*
* @since v.2.0
*
* @return void
*/
function wppb_register_general_settings_submenu_page() {
add_submenu_page( 'profile-builder', __( 'General Settings', 'profile-builder' ), __( 'General Settings', 'profile-builder' ), 'manage_options', 'profile-builder-general-settings', 'wppb_general_settings_content' );
}
add_action( 'admin_menu', 'wppb_register_general_settings_submenu_page', 3 );
function wppb_generate_default_settings_defaults(){
add_option( 'wppb_general_settings', array( 'extraFieldsLayout' => 'default', 'emailConfirmation' => 'no', 'activationLandingPage' => '', 'adminApproval' => 'no', 'loginWith' => 'usernameemail', 'rolesEditor' => 'no' ) );
}
/**
* Function that adds content to the "General Settings" submenu page
*
* @since v.2.0
*
* @return string
*/
function wppb_general_settings_content() {
wppb_generate_default_settings_defaults();
?>
<div class="wrap wppb-wrap">
<form method="post" action="options.php#general-settings">
<?php $wppb_generalSettings = get_option( 'wppb_general_settings' ); ?>
<?php settings_fields( 'wppb_general_settings' ); ?>
<h2><?php _e( 'General Settings', 'profile-builder' ); ?></h2>
<table class="form-table">
<tr>
<th scope="row">
<?php _e( "Load Profile Builder's own CSS file in the front-end:", "profile-builder" ); ?>
</th>
<td>
<label><input type="checkbox" name="wppb_general_settings[extraFieldsLayout]"<?php echo ( ( isset( $wppb_generalSettings['extraFieldsLayout'] ) && ( $wppb_generalSettings['extraFieldsLayout'] == 'default' ) ) ? ' checked' : '' ); ?> value="default" class="wppb-select"><?php _e( 'Yes', 'profile-builder' ); ?></label>
<ul>
<li class="description"><?php printf( __( 'You can find the default file here: %1$s', 'profile-builder' ), '<a href="'.dirname( plugin_dir_url( __FILE__ ) ).'/assets/css/style-front-end.css" target="_blank">'.dirname( dirname( plugin_basename( __FILE__ ) ) ).'\assets\css\style-front-end.css</a>' ); ?></li>
</ul>
</td>
</tr>
<tr>
<th scope="row">
<?php _e( '"Email Confirmation" Activated:', 'profile-builder' );?>
</th>
<td>
<select name="wppb_general_settings[emailConfirmation]" class="wppb-select" id="wppb_settings_email_confirmation" onchange="wppb_display_page_select(this.value)">
<option value="yes" <?php if ( $wppb_generalSettings['emailConfirmation'] == 'yes' ) echo 'selected'; ?>><?php _e( 'Yes', 'profile-builder' ); ?></option>
<option value="no" <?php if ( $wppb_generalSettings['emailConfirmation'] == 'no' ) echo 'selected'; ?>><?php _e( 'No', 'profile-builder' ); ?></option>
</select>
<ul>
<li class="description"><?php _e( 'This works with front-end forms only. Recommended to redirect WP default registration to a Profile Builder one using "Custom Redirects" module.', 'profile-builder' ); ?></li>
<?php if ( $wppb_generalSettings['emailConfirmation'] == 'yes' ) { ?>
<li class="description dynamic1"><?php printf( __( 'You can find a list of unconfirmed email addresses %1$sUsers > All Users > Email Confirmation%2$s.', 'profile-builder' ), '<a href="'.get_bloginfo( 'url' ).'/wp-admin/users.php?page=unconfirmed_emails">', '</a>' )?></li>
<?php } ?>
</ul>
</td>
</tr>
<tr id="wppb-settings-activation-page">
<th scope="row">
<?php _e( '"Email Confirmation" Landing Page:', 'profile-builder' ); ?>
</th>
<td>
<select name="wppb_general_settings[activationLandingPage]" class="wppb-select">
<option value="" <?php if ( empty( $wppb_generalSettings['emailConfirmation'] ) ) echo 'selected'; ?>></option>
<optgroup label="<?php _e( 'Existing Pages', 'profile-builder' ); ?>">
<?php
$pages = get_pages( apply_filters( 'wppb_page_args_filter', array( 'sort_order' => 'ASC', 'sort_column' => 'post_title', 'post_type' => 'page', 'post_status' => array( 'publish' ) ) ) );
foreach ( $pages as $key => $value ){
echo '<option value="'.$value->ID.'"';
if ( $wppb_generalSettings['activationLandingPage'] == $value->ID )
echo ' selected';
echo '>' . $value->post_title . '</option>';
}
?>
</optgroup>
</select>
<p class="description">
<?php _e( 'Specify the page where the users will be directed when confirming the email account. This page can differ from the register page(s) and can be changed at any time. If none selected, a simple confirmation page will be displayed for the user.', 'profile-builder' ); ?>
</p>
</td>
</tr>
<?php
if ( file_exists( WPPB_PLUGIN_DIR.'/features/admin-approval/admin-approval.php' ) ){
?>
<tr>
<th scope="row">
<?php _e( '"Admin Approval" Activated:', 'profile-builder' ); ?>
</th>
<td>
<select id="adminApprovalSelect" name="wppb_general_settings[adminApproval]" class="wppb-select" onchange="wppb_display_page_select_aa(this.value)">
<option value="yes" <?php if( !empty( $wppb_generalSettings['adminApproval'] ) && $wppb_generalSettings['adminApproval'] == 'yes' ) echo 'selected'; ?>><?php _e( 'Yes', 'profile-builder' ); ?></option>
<option value="no" <?php if( !empty( $wppb_generalSettings['adminApproval'] ) && $wppb_generalSettings['adminApproval'] == 'no' ) echo 'selected'; ?>><?php _e( 'No', 'profile-builder' ); ?></option>
</select>
<ul>
<li class="description dynamic2"><?php printf( __( 'You can find a list of users at %1$sUsers > All Users > Admin Approval%2$s.', 'profile-builder' ), '<a href="'.get_bloginfo( 'url' ).'/wp-admin/users.php?page=admin_approval&orderby=registered&order=desc">', '</a>' )?></li>
<ul>
</td>
</tr>
<tr class="dynamic2">
<th scope="row">
<?php _e( '"Admin Approval" on User Role:', 'profile-builder' ); ?>
</th>
<td>
<div id="wrap">
<?php
$wppb_userRoles = wppb_adminApproval_onUserRole();
if( ! empty( $wppb_userRoles ) ) {
foreach( $wppb_userRoles as $role => $role_name ) {
echo '<label><input type="checkbox" id="adminApprovalOnUserRoleCheckbox" name="wppb_general_settings[adminApprovalOnUserRole][]" class="wppb-checkboxes" value="' . esc_attr( $role ) . '"';
if( ! empty( $wppb_generalSettings['adminApprovalOnUserRole'] ) && in_array( $role, $wppb_generalSettings['adminApprovalOnUserRole'] ) ) echo ' checked';
if( empty( $wppb_generalSettings['adminApprovalOnUserRole'] ) ) echo ' checked';
echo '>';
echo $role_name . '</label><br>';
}
}
?>
</div>
<ul>
<li class="description"><?php printf( __( 'Select on what user roles to activate Admin Approval.', 'profile-builder' ) ) ?></li>
<ul>
</td>
</tr>
<?php } ?>
<?php
if( file_exists( WPPB_PLUGIN_DIR.'/features/roles-editor/roles-editor.php' ) ) {
?>
<tr>
<th scope="row">
<?php _e( '"Roles Editor" Activated:', 'profile-builder' ); ?>
</th>
<td>
<select id="rolesEditorSelect" name="wppb_general_settings[rolesEditor]" class="wppb-select" onchange="wppb_display_page_select_re(this.value)">
<option value="no" <?php if( !empty( $wppb_generalSettings['rolesEditor'] ) && $wppb_generalSettings['rolesEditor'] == 'no' ) echo 'selected'; ?>><?php _e( 'No', 'profile-builder' ); ?></option>
<option value="yes" <?php if( !empty( $wppb_generalSettings['rolesEditor'] ) && $wppb_generalSettings['rolesEditor'] == 'yes' ) echo 'selected'; ?>><?php _e( 'Yes', 'profile-builder' ); ?></option>
</select>
<ul>
<li class="description dynamic3"><?php printf( __( 'You can add / edit user roles at %1$sUsers > Roles Editor%2$s.', 'profile-builder' ), '<a href="'.get_bloginfo( 'url' ).'/wp-admin/edit.php?post_type=wppb-roles-editor">', '</a>' )?></li>
<ul>
</td>
</tr>
<?php } ?>
<?php
if ( PROFILE_BUILDER == 'Profile Builder Free' ) {
?>
<tr>
<th scope="row">
<?php _e( '"Admin Approval" Feature:', 'profile-builder' ); ?>
</th>
<td>
<p><em> <?php printf( __( 'You decide who is a user on your website. Get notified via email or approve multiple users at once from the WordPress UI. Enable Admin Approval by upgrading to %1$sHobbyist or PRO versions%2$s.', 'profile-builder' ),'<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wpbackend&utm_medium=clientsite&utm_content=general-settings-link&utm_campaign=PBFree">', '</a>' )?></em></p>
</td>
</tr>
<?php } ?>
<tr>
<th scope="row">
<?php _e( 'Allow Users to Log in With:', 'profile-builder' ); ?>
</th>
<td>
<select name="wppb_general_settings[loginWith]" class="wppb-select">
<option value="usernameemail" <?php if ( $wppb_generalSettings['loginWith'] == 'usernameemail' ) echo 'selected'; ?>><?php _e( 'Username and Email', 'profile-builder' ); ?></option>
<option value="username" <?php if ( $wppb_generalSettings['loginWith'] == 'username' ) echo 'selected'; ?>><?php _e( 'Username', 'profile-builder' ); ?></option>
<option value="email" <?php if ( $wppb_generalSettings['loginWith'] == 'email' ) echo 'selected'; ?>><?php _e( 'Email', 'profile-builder' ); ?></option>
</select>
<ul>
<li class="description"><?php _e( '"Username and Email" - users can Log In with both Username and Email.', 'profile-builder' ); ?></li>
<li class="description"><?php _e( '"Username" - users can Log In only with Username.', 'profile-builder' ); ?></li>
<li class="description"><?php _e( '"Email" - users can Log In only with Email.', 'profile-builder' ); ?></li>
</ul>
</td>
</tr>
<tr>
<th scope="row">
<?php _e( 'Minimum Password Length:', 'profile-builder' ); ?>
</th>
<td>
<input type="text" name="wppb_general_settings[minimum_password_length]" class="wppb-text" value="<?php if( !empty( $wppb_generalSettings['minimum_password_length'] ) ) echo esc_attr( $wppb_generalSettings['minimum_password_length'] ); ?>"/>
<ul>
<li class="description"><?php _e( 'Enter the minimum characters the password should have. Leave empty for no minimum limit', 'profile-builder' ); ?> </li>
</ul>
</td>
</tr>
<tr>
<th scope="row">
<?php _e( 'Minimum Password Strength:', 'profile-builder' ); ?>
</th>
<td>
<select name="wppb_general_settings[minimum_password_strength]" class="wppb-select">
<option value=""><?php _e( 'Disabled', 'profile-builder' ); ?></option>
<option value="short" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'short' ) echo 'selected'; ?>><?php _e( 'Very weak', 'profile-builder' ); ?></option>
<option value="bad" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'bad' ) echo 'selected'; ?>><?php _e( 'Weak', 'profile-builder' ); ?></option>
<option value="good" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'good' ) echo 'selected'; ?>><?php _e( 'Medium', 'profile-builder' ); ?></option>
<option value="strong" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'strong' ) echo 'selected'; ?>><?php _e( 'Strong', 'profile-builder' ); ?></option>
</select>
</td>
</tr>
<?php do_action( 'wppb_extra_general_settings', $wppb_generalSettings ); ?>
</table>
<input type="hidden" name="action" value="update" />
<p class="submit"><input type="submit" class="button-primary" value="<?php _e( 'Save Changes' ); ?>" /></p>
</form>
</div>
<?php
}
/*
* Function that sanitizes the general settings
*
* @param array $wppb_generalSettings
*
* @since v.2.0.7
*/
function wppb_general_settings_sanitize( $wppb_generalSettings ) {
$wppb_generalSettings = apply_filters( 'wppb_general_settings_sanitize_extra', $wppb_generalSettings );
if( !empty( $wppb_generalSettings ) ){
foreach( $wppb_generalSettings as $settings_name => $settings_value ){
if( $settings_name == "minimum_password_length" || $settings_name == "activationLandingPage" )
$wppb_generalSettings[$settings_name] = filter_var( $settings_value, FILTER_SANITIZE_NUMBER_INT );
elseif( $settings_name == "extraFieldsLayout" || $settings_name == "emailConfirmation" || $settings_name == "adminApproval" || $settings_name == "loginWith" || $settings_name == "minimum_password_strength" )
$wppb_generalSettings[$settings_name] = filter_var( $settings_value, FILTER_SANITIZE_STRING );
elseif( $settings_name == "adminApprovalOnUserRole" ){
if( is_array( $settings_value ) && !empty( $settings_value ) ){
foreach( $settings_value as $key => $value ){
$wppb_generalSettings[$settings_name][$key] = filter_var( $value, FILTER_SANITIZE_STRING );
}
}
}
}
}
return $wppb_generalSettings;
}
/*
* Function that pushes settings errors to the user
*
* @since v.2.0.7
*/
function wppb_general_settings_admin_notices() {
settings_errors( 'wppb_general_settings' );
}
add_action( 'admin_notices', 'wppb_general_settings_admin_notices' );
/*
* Function that return user roles
*
* @since v.2.2.0
*
* @return array
*/
function wppb_adminApproval_onUserRole() {
global $wp_roles;
$wp_roles = new WP_Roles();
$roles = $wp_roles->get_names();
unset( $roles['administrator'] );
return $roles;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,243 +1,243 @@
<?php
/**
* Function that creates the "Paid Accounts" submenu page
*
* @since v.2.0
*
* @return void
*/
function wppb_register_pms_cross_promo() {
add_submenu_page( 'null', __( 'Paid Accounts', 'profile-builder' ), __( 'Paid Accounts', 'profile-builder' ), 'manage_options', 'profile-builder-pms-promo', 'wppb_pms_cross_promo' );
}
add_action( 'admin_menu', 'wppb_register_pms_cross_promo', 2 );
/**
* Function that adds content to the "Paid Accounts" submenu page
*
* @since v.2.0
*
* @return string
*/
function wppb_pms_cross_promo() {
?>
<div class="wrap wppb-wrap wppb-info-wrap">
<div class="wppb-badge wppb-pb-pms"></div>
<h1>Users can pay for an account with<br/> <small style="font-size: 30px; letter-spacing: 0.008em;">Profile Builder and Paid Member Subscriptions</small></h1>
<hr />
<div class="wppb-row">
<p>One of the most requested features in Profile Builder was for users to be able to pay for an account.</p>
<p>Now that's possible using the free WordPress plugin - <a href="https://www.cozmoslabs.com/wordpress-paid-member-subscriptions/?utm_source=wpbackend&utm_medium=clientsite&utm_content=pb-pms-promo&utm_campaign=PBFree">Paid Member Subscriptions</a>.</p>
</div>
<h2 class="wppb-callout"><?php _e( 'Paid Member Subscriptions - a free WordPress plugin', 'profile-builder' ); ?></h2>
<hr/>
<div class="wppb-row wppb-2-col">
<div>
<p><?php _e( 'With the new Subscriptions Field in Profile Builder, your registration forms will allow your users to sign up for paid accounts.', 'profile-builder' ); ?></p>
<p>Other features of Paid Member Subscriptions are:</p>
<ul>
<li><?php _e( 'Paid & Free Subscriptions', 'profile-builder' ); ?></li>
<li><?php _e( 'Restrict Content', 'profile-builder' ); ?></li>
<li><?php _e( 'Member Management', 'profile-builder' ); ?></li>
<li><?php _e( 'Email Templates', 'profile-builder' ); ?> </li>
<li><?php _e( 'Account Management', 'profile-builder' ); ?> </li>
<li><?php _e( 'Subscription Management', 'profile-builder' ); ?> </li>
<li><?php _e( 'Payment Management', 'profile-builder' ); ?> </li>
</ul>
</div>
<div>
<div>
<?php
$wppb_get_all_plugins = get_plugins();
$wppb_get_active_plugins = get_option('active_plugins');
$ajax_nonce = wp_create_nonce("wppb-activate-addon");
$pms_add_on_exists = 0;
$pms_add_on_is_active = 0;
$pms_add_on_is_network_active = 0;
// Check to see if add-on is in the plugins folder
foreach ($wppb_get_all_plugins as $wppb_plugin_key => $wppb_plugin) {
if( strtolower($wppb_plugin['Name']) == strtolower( 'Paid Member Subscriptions' ) && strpos(strtolower($wppb_plugin['AuthorName']), strtolower('Cozmoslabs')) !== false) {
$pms_add_on_exists = 1;
if (in_array($wppb_plugin_key, $wppb_get_active_plugins)) {
$pms_add_on_is_active = 1;
}
// Consider the add-on active if it's network active
if (is_plugin_active_for_network($wppb_plugin_key)) {
$pms_add_on_is_network_active = 1;
$pms_add_on_is_active = 1;
}
$plugin_file = $wppb_plugin_key;
}
}
?>
<span id="wppb-add-on-activate-button-text" class="wppb-add-on-user-messages"><?php echo __( 'Activate', 'profile-builder' ); ?></span>
<span id="wppb-add-on-downloading-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Downloading and installing...', 'profile-builder' ); ?></span>
<span id="wppb-add-on-download-finished-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Installation complete', 'profile-builder' ); ?></span>
<span id="wppb-add-on-activated-button-text" class="wppb-add-on-user-messages"><?php echo __( 'Plugin is Active', 'profile-builder' ); ?></span>
<span id="wppb-add-on-activated-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Plugin has been activated', 'profile-builder' ) ?></span>
<span id="wppb-add-on-activated-error-button-text" class="wppb-add-on-user-messages"><?php echo __( 'Retry Install', 'profile-builder' ) ?></span>
<span id="wppb-add-on-is-active-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Plugin is <strong>active</strong>', 'profile-builder' ); ?></span>
<span id="wppb-add-on-is-not-active-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Plugin is <strong>inactive</strong>', 'profile-builder' ); ?></span>
<span id="wppb-add-on-deactivate-button-text" class="wppb-add-on-user-messages"><?php echo __( 'Deactivate', 'profile-builder' ) ?></span>
<span id="wppb-add-on-deactivated-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Plugin has been deactivated.', 'profile-builder' ) ?></span>
<div class="plugin-card wppb-recommended-plugin wppb-add-on" style="width: 111%;">
<div class="plugin-card-top">
<a target="_blank" href="http://wordpress.org/plugins/paid-member-subscriptions/">
<img src="<?php echo plugins_url( '../assets/images/pms-recommended.png', __FILE__ ); ?>" width="100%">
</a>
<h3 class="wppb-add-on-title">
<a target="_blank" href="http://wordpress.org/plugins/paid-member-subscriptions/">Paid Member Subscriptions</a>
</h3>
<h3 class="wppb-add-on-price"><?php _e( 'Free', 'profile-builder' ) ?></h3>
<p class="wppb-add-on-description">
<?php _e( 'Accept user payments, create subscription plans and restrict content on your website.', 'profile-builder' ) ?>
<a href="<?php admin_url();?>plugin-install.php?tab=plugin-information&plugin=paid-member-subscriptions&TB_iframe=true&width=772&height=875" class="thickbox" aria-label="More information about Paid Member Subscriptions - membership & content restriction" data-title="Paid Member Subscriptions - membership & content restriction"><?php _e( 'More Details' ); ?></a>
</p>
</div>
<div class="plugin-card-bottom wppb-add-on-compatible">
<?php
if ($pms_add_on_exists) {
// Display activate/deactivate buttons
if (!$pms_add_on_is_active) {
echo '<a class="wppb-add-on-activate right button button-primary" href="' . $plugin_file . '" data-nonce="' . $ajax_nonce . '">' . __('Activate', 'profile-builder') . '</a>';
// If add-on is network activated don't allow deactivation
} elseif (!$pms_add_on_is_network_active) {
echo '<a class="wppb-add-on-deactivate right button button-primary" href="' . $plugin_file . '" data-nonce="' . $ajax_nonce . '">' . __('Deactivate', 'profile-builder') . '</a>';
}
// Display message to the user
if( !$pms_add_on_is_active ){
echo '<span class="dashicons dashicons-no-alt"></span><span class="wppb-add-on-message">' . __('Plugin is <strong>inactive</strong>', 'profile-builder') . '</span>';
} else {
echo '<span class="dashicons dashicons-yes"></span><span class="wppb-add-on-message">' . __('Plugin is <strong>active</strong>', 'profile-builder') . '</span>';
}
} else {
// If we're on a multisite don't add the wpp-add-on-download class to the button so we don't fire the js that
// handles the in-page download
if (is_multisite()) {
$wppb_paid_link_class = 'button-primary';
$wppb_paid_link_text = __('Download Now', 'profile-builder' );
} else {
$wppb_paid_link_class = 'button-primary wppb-add-on-download';
$wppb_paid_link_text = __('Install Now', 'profile-builder');
}
echo '<a target="_blank" class="right button ' . $wppb_paid_link_class . '" href="https://downloads.wordpress.org/plugin/paid-member-subscriptions.zip" data-add-on-slug="paid-member-subscriptions" data-add-on-name="Paid Member Subscriptions" data-nonce="' . $ajax_nonce . '">' . $wppb_paid_link_text . '</a>';
echo '<span class="dashicons dashicons-yes"></span><span class="wppb-add-on-message">' . __('Compatible with your version of Profile Builder.', 'profile-builder') . '</span>';
}
?>
<div class="spinner"></div>
<span class="wppb-add-on-user-messages wppb-error-manual-install"><?php printf(__('Could not install plugin. Retry or <a href="%s" target="_blank">install manually</a>.', 'profile-builder'), esc_url( 'http://www.wordpress.org/plugins/paid-member-subscriptions' )) ?></a>.</span>
</div>
</div>
</div>
</div>
</div>
<h2 class="wppb-callout"><?php _e( 'Step by Step Quick Setup', 'profile-builder' ); ?></h2>
<hr/>
<p>Setting up Paid Member Subscriptions opens the door to paid user accounts. </p>
<div class="wrap wppb-wrap wppb-1-3-col">
<div><h3>Create Subscription Plans</h3>
<p>With Paid Member Subscriptions its fairly easy to create tiered subscription plans for your users. </p>
<p>Adding a new subscription gives you access to the following options to set up: subscription name, description, duration, the price, status and user role.</p>
</div>
<div style="text-align: right">
<p><img src="<?php echo WPPB_PLUGIN_URL; ?>assets/images/pms_all_subscriptions-600x336.jpg" alt="paid subscription plans"/></p>
</div>
</div>
<div class="wrap wppb-wrap wppb-1-3-col">
<div><h3>Add Subscriptions field to Profile Builder -> Manage Fields</h3>
<p>The new Subscription Plans field will add a list of radio buttons with membership details to Profile Builder registration forms.</p>
</div>
<div style="text-align: right">
<p><img src="<?php echo WPPB_PLUGIN_URL; ?>assets/images/pms_pb_add_subscription-600x471.png" alt="manage fields subscription plans"/></p>
</div>
</div>
<div class="wrap wppb-wrap wppb-1-3-col">
<div><h3>Start getting user payments</h3>
<p>To finalize registration for a paid account, users will need to complete the payment.</p>
<p>Members created with Profile Builder registration form will have the user role of the selected subscription.</p>
</div>
<div style="text-align: right">
<p><img src="<?php echo WPPB_PLUGIN_URL; ?>assets/images/pms_pb_register_page-600x618.png" alt="register payed accounts"/></p>
</div>
</div>
<div id="pms-bottom-install" class="wppb-add-on">
<div class="plugin-card-bottom wppb-add-on-compatible">
<?php
if ($pms_add_on_exists) {
// Display activate/deactivate buttons
if (!$pms_add_on_is_active) {
echo '<a class="wppb-add-on-activate right button button-secondary" href="' . $plugin_file . '" data-nonce="' . $ajax_nonce . '">' . __('Activate', 'profile-builder') . '</a>';
// If add-on is network activated don't allow deactivation
} elseif (!$pms_add_on_is_network_active) {
echo '<a class="wppb-add-on-deactivate right button button-secondary" href="' . $plugin_file . '" data-nonce="' . $ajax_nonce . '">' . __('Deactivate', 'profile-builder') . '</a>';
}
// Display message to the user
if( !$pms_add_on_is_active ){
echo '<span class="dashicons dashicons-no-alt"></span><span class="wppb-add-on-message">' . __('Plugin is <strong>inactive</strong>', 'profile-builder') . '</span>';
} else {
echo '<span class="dashicons dashicons-yes"></span><span class="wppb-add-on-message">' . __('Plugin is <strong>active</strong>', 'profile-builder') . '</span>';
}
} else {
// If we're on a multisite don't add the wpp-add-on-download class to the button so we don't fire the js that
// handles the in-page download
if (is_multisite()) {
$wppb_paid_link_class = 'button-secondary';
$wppb_paid_link_text = __('Download Now', 'profile-builder' );
} else {
$wppb_paid_link_class = 'button-secondary wppb-add-on-download';
$wppb_paid_link_text = __('Install Now', 'profile-builder');
}
echo '<a target="_blank" class="right button ' . $wppb_paid_link_class . '" href="https://downloads.wordpress.org/plugin/paid-member-subscriptions.zip" data-add-on-slug="paid-member-subscriptions" data-add-on-name="Paid Member Subscriptions" data-nonce="' . $ajax_nonce . '">' . $wppb_paid_link_text . '</a>';
echo '<span class="dashicons dashicons-yes"></span><span class="wppb-add-on-message">' . __('Compatible with your version of Profile Builder.', 'profile-builder') . '</span>';
}
?>
<div class="spinner"></div>
<?php /* <span class="wppb-add-on-user-messages wppb-error-manual-install"><?php printf(__('Could not install plugin. Retry or <a href="%s" target="_blank">install manually</a>.', 'profile-builder'), esc_url( 'http://www.wordpress.org/plugins/paid-member-subscriptions' )) ?></a>.</span> */ ?>
</div>
</div>
</div>
<?php
}
/*
* Instantiate a new notification for the PMS cross Promotion
*
* @Since 2.2.5
*/
/*
if ( !isset($_GET['page']) || $_GET['page'] != 'profile-builder-pms-promo'){
new WPPB_Add_General_Notices('wppb_pms_cross_promo',
sprintf(__('Allow your users to have <strong>paid accounts with Profile Builder</strong>. %1$sFind out how >%2$s %3$sDismiss%4$s', 'profile-builder'), "<a href='" . admin_url('options.php?page=profile-builder-pms-promo') . "'>", "</a>", "<a class='wppb-dismiss-notification' href='" . esc_url( add_query_arg('wppb_pms_cross_promo_dismiss_notification', '0') ) . "'>", "</a>"),
'pms-cross-promo');
}
*/
<?php
/**
* Function that creates the "Paid Accounts" submenu page
*
* @since v.2.0
*
* @return void
*/
function wppb_register_pms_cross_promo() {
add_submenu_page( 'null', __( 'Paid Accounts', 'profile-builder' ), __( 'Paid Accounts', 'profile-builder' ), 'manage_options', 'profile-builder-pms-promo', 'wppb_pms_cross_promo' );
}
add_action( 'admin_menu', 'wppb_register_pms_cross_promo', 2 );
/**
* Function that adds content to the "Paid Accounts" submenu page
*
* @since v.2.0
*
* @return string
*/
function wppb_pms_cross_promo() {
?>
<div class="wrap wppb-wrap wppb-info-wrap">
<div class="wppb-badge wppb-pb-pms"></div>
<h1>Users can pay for an account with<br/> <small style="font-size: 30px; letter-spacing: 0.008em;">Profile Builder and Paid Member Subscriptions</small></h1>
<hr />
<div class="wppb-row">
<p>One of the most requested features in Profile Builder was for users to be able to pay for an account.</p>
<p>Now that's possible using the free WordPress plugin - <a href="https://www.cozmoslabs.com/wordpress-paid-member-subscriptions/?utm_source=wpbackend&utm_medium=clientsite&utm_content=pb-pms-promo&utm_campaign=PBFree">Paid Member Subscriptions</a>.</p>
</div>
<h2 class="wppb-callout"><?php _e( 'Paid Member Subscriptions - a free WordPress plugin', 'profile-builder' ); ?></h2>
<hr/>
<div class="wppb-row wppb-2-col">
<div>
<p><?php _e( 'With the new Subscriptions Field in Profile Builder, your registration forms will allow your users to sign up for paid accounts.', 'profile-builder' ); ?></p>
<p>Other features of Paid Member Subscriptions are:</p>
<ul>
<li><?php _e( 'Paid & Free Subscriptions', 'profile-builder' ); ?></li>
<li><?php _e( 'Restrict Content', 'profile-builder' ); ?></li>
<li><?php _e( 'Member Management', 'profile-builder' ); ?></li>
<li><?php _e( 'Email Templates', 'profile-builder' ); ?> </li>
<li><?php _e( 'Account Management', 'profile-builder' ); ?> </li>
<li><?php _e( 'Subscription Management', 'profile-builder' ); ?> </li>
<li><?php _e( 'Payment Management', 'profile-builder' ); ?> </li>
</ul>
</div>
<div>
<div>
<?php
$wppb_get_all_plugins = get_plugins();
$wppb_get_active_plugins = get_option('active_plugins');
$ajax_nonce = wp_create_nonce("wppb-activate-addon");
$pms_add_on_exists = 0;
$pms_add_on_is_active = 0;
$pms_add_on_is_network_active = 0;
// Check to see if add-on is in the plugins folder
foreach ($wppb_get_all_plugins as $wppb_plugin_key => $wppb_plugin) {
if( strtolower($wppb_plugin['Name']) == strtolower( 'Paid Member Subscriptions' ) && strpos(strtolower($wppb_plugin['AuthorName']), strtolower('Cozmoslabs')) !== false) {
$pms_add_on_exists = 1;
if (in_array($wppb_plugin_key, $wppb_get_active_plugins)) {
$pms_add_on_is_active = 1;
}
// Consider the add-on active if it's network active
if (is_plugin_active_for_network($wppb_plugin_key)) {
$pms_add_on_is_network_active = 1;
$pms_add_on_is_active = 1;
}
$plugin_file = $wppb_plugin_key;
}
}
?>
<span id="wppb-add-on-activate-button-text" class="wppb-add-on-user-messages"><?php echo __( 'Activate', 'profile-builder' ); ?></span>
<span id="wppb-add-on-downloading-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Downloading and installing...', 'profile-builder' ); ?></span>
<span id="wppb-add-on-download-finished-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Installation complete', 'profile-builder' ); ?></span>
<span id="wppb-add-on-activated-button-text" class="wppb-add-on-user-messages"><?php echo __( 'Plugin is Active', 'profile-builder' ); ?></span>
<span id="wppb-add-on-activated-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Plugin has been activated', 'profile-builder' ) ?></span>
<span id="wppb-add-on-activated-error-button-text" class="wppb-add-on-user-messages"><?php echo __( 'Retry Install', 'profile-builder' ) ?></span>
<span id="wppb-add-on-is-active-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Plugin is <strong>active</strong>', 'profile-builder' ); ?></span>
<span id="wppb-add-on-is-not-active-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Plugin is <strong>inactive</strong>', 'profile-builder' ); ?></span>
<span id="wppb-add-on-deactivate-button-text" class="wppb-add-on-user-messages"><?php echo __( 'Deactivate', 'profile-builder' ) ?></span>
<span id="wppb-add-on-deactivated-message-text" class="wppb-add-on-user-messages"><?php echo __( 'Plugin has been deactivated.', 'profile-builder' ) ?></span>
<div class="plugin-card wppb-recommended-plugin wppb-add-on" style="width: 111%;">
<div class="plugin-card-top">
<a target="_blank" href="http://wordpress.org/plugins/paid-member-subscriptions/">
<img src="<?php echo plugins_url( '../assets/images/pms-recommended.png', __FILE__ ); ?>" width="100%">
</a>
<h3 class="wppb-add-on-title">
<a target="_blank" href="http://wordpress.org/plugins/paid-member-subscriptions/">Paid Member Subscriptions</a>
</h3>
<h3 class="wppb-add-on-price"><?php _e( 'Free', 'profile-builder' ) ?></h3>
<p class="wppb-add-on-description">
<?php _e( 'Accept user payments, create subscription plans and restrict content on your website.', 'profile-builder' ) ?>
<a href="<?php admin_url();?>plugin-install.php?tab=plugin-information&plugin=paid-member-subscriptions&TB_iframe=true&width=772&height=875" class="thickbox" aria-label="More information about Paid Member Subscriptions - membership & content restriction" data-title="Paid Member Subscriptions - membership & content restriction"><?php _e( 'More Details' ); ?></a>
</p>
</div>
<div class="plugin-card-bottom wppb-add-on-compatible">
<?php
if ($pms_add_on_exists) {
// Display activate/deactivate buttons
if (!$pms_add_on_is_active) {
echo '<a class="wppb-add-on-activate right button button-primary" href="' . $plugin_file . '" data-nonce="' . $ajax_nonce . '">' . __('Activate', 'profile-builder') . '</a>';
// If add-on is network activated don't allow deactivation
} elseif (!$pms_add_on_is_network_active) {
echo '<a class="wppb-add-on-deactivate right button button-primary" href="' . $plugin_file . '" data-nonce="' . $ajax_nonce . '">' . __('Deactivate', 'profile-builder') . '</a>';
}
// Display message to the user
if( !$pms_add_on_is_active ){
echo '<span class="dashicons dashicons-no-alt"></span><span class="wppb-add-on-message">' . __('Plugin is <strong>inactive</strong>', 'profile-builder') . '</span>';
} else {
echo '<span class="dashicons dashicons-yes"></span><span class="wppb-add-on-message">' . __('Plugin is <strong>active</strong>', 'profile-builder') . '</span>';
}
} else {
// If we're on a multisite don't add the wpp-add-on-download class to the button so we don't fire the js that
// handles the in-page download
if (is_multisite()) {
$wppb_paid_link_class = 'button-primary';
$wppb_paid_link_text = __('Download Now', 'profile-builder' );
} else {
$wppb_paid_link_class = 'button-primary wppb-add-on-download';
$wppb_paid_link_text = __('Install Now', 'profile-builder');
}
echo '<a target="_blank" class="right button ' . $wppb_paid_link_class . '" href="https://downloads.wordpress.org/plugin/paid-member-subscriptions.zip" data-add-on-slug="paid-member-subscriptions" data-add-on-name="Paid Member Subscriptions" data-nonce="' . $ajax_nonce . '">' . $wppb_paid_link_text . '</a>';
echo '<span class="dashicons dashicons-yes"></span><span class="wppb-add-on-message">' . __('Compatible with your version of Profile Builder.', 'profile-builder') . '</span>';
}
?>
<div class="spinner"></div>
<span class="wppb-add-on-user-messages wppb-error-manual-install"><?php printf(__('Could not install plugin. Retry or <a href="%s" target="_blank">install manually</a>.', 'profile-builder'), esc_url( 'http://www.wordpress.org/plugins/paid-member-subscriptions' )) ?></a>.</span>
</div>
</div>
</div>
</div>
</div>
<h2 class="wppb-callout"><?php _e( 'Step by Step Quick Setup', 'profile-builder' ); ?></h2>
<hr/>
<p>Setting up Paid Member Subscriptions opens the door to paid user accounts. </p>
<div class="wrap wppb-wrap wppb-1-3-col">
<div><h3>Create Subscription Plans</h3>
<p>With Paid Member Subscriptions its fairly easy to create tiered subscription plans for your users. </p>
<p>Adding a new subscription gives you access to the following options to set up: subscription name, description, duration, the price, status and user role.</p>
</div>
<div style="text-align: right">
<p><img src="<?php echo WPPB_PLUGIN_URL; ?>assets/images/pms_all_subscriptions-600x336.jpg" alt="paid subscription plans"/></p>
</div>
</div>
<div class="wrap wppb-wrap wppb-1-3-col">
<div><h3>Add Subscriptions field to Profile Builder -> Manage Fields</h3>
<p>The new Subscription Plans field will add a list of radio buttons with membership details to Profile Builder registration forms.</p>
</div>
<div style="text-align: right">
<p><img src="<?php echo WPPB_PLUGIN_URL; ?>assets/images/pms_pb_add_subscription-600x471.png" alt="manage fields subscription plans"/></p>
</div>
</div>
<div class="wrap wppb-wrap wppb-1-3-col">
<div><h3>Start getting user payments</h3>
<p>To finalize registration for a paid account, users will need to complete the payment.</p>
<p>Members created with Profile Builder registration form will have the user role of the selected subscription.</p>
</div>
<div style="text-align: right">
<p><img src="<?php echo WPPB_PLUGIN_URL; ?>assets/images/pms_pb_register_page-600x618.png" alt="register payed accounts"/></p>
</div>
</div>
<div id="pms-bottom-install" class="wppb-add-on">
<div class="plugin-card-bottom wppb-add-on-compatible">
<?php
if ($pms_add_on_exists) {
// Display activate/deactivate buttons
if (!$pms_add_on_is_active) {
echo '<a class="wppb-add-on-activate right button button-secondary" href="' . $plugin_file . '" data-nonce="' . $ajax_nonce . '">' . __('Activate', 'profile-builder') . '</a>';
// If add-on is network activated don't allow deactivation
} elseif (!$pms_add_on_is_network_active) {
echo '<a class="wppb-add-on-deactivate right button button-secondary" href="' . $plugin_file . '" data-nonce="' . $ajax_nonce . '">' . __('Deactivate', 'profile-builder') . '</a>';
}
// Display message to the user
if( !$pms_add_on_is_active ){
echo '<span class="dashicons dashicons-no-alt"></span><span class="wppb-add-on-message">' . __('Plugin is <strong>inactive</strong>', 'profile-builder') . '</span>';
} else {
echo '<span class="dashicons dashicons-yes"></span><span class="wppb-add-on-message">' . __('Plugin is <strong>active</strong>', 'profile-builder') . '</span>';
}
} else {
// If we're on a multisite don't add the wpp-add-on-download class to the button so we don't fire the js that
// handles the in-page download
if (is_multisite()) {
$wppb_paid_link_class = 'button-secondary';
$wppb_paid_link_text = __('Download Now', 'profile-builder' );
} else {
$wppb_paid_link_class = 'button-secondary wppb-add-on-download';
$wppb_paid_link_text = __('Install Now', 'profile-builder');
}
echo '<a target="_blank" class="right button ' . $wppb_paid_link_class . '" href="https://downloads.wordpress.org/plugin/paid-member-subscriptions.zip" data-add-on-slug="paid-member-subscriptions" data-add-on-name="Paid Member Subscriptions" data-nonce="' . $ajax_nonce . '">' . $wppb_paid_link_text . '</a>';
echo '<span class="dashicons dashicons-yes"></span><span class="wppb-add-on-message">' . __('Compatible with your version of Profile Builder.', 'profile-builder') . '</span>';
}
?>
<div class="spinner"></div>
<?php /* <span class="wppb-add-on-user-messages wppb-error-manual-install"><?php printf(__('Could not install plugin. Retry or <a href="%s" target="_blank">install manually</a>.', 'profile-builder'), esc_url( 'http://www.wordpress.org/plugins/paid-member-subscriptions' )) ?></a>.</span> */ ?>
</div>
</div>
</div>
<?php
}
/*
* Instantiate a new notification for the PMS cross Promotion
*
* @Since 2.2.5
*/
/*
if ( !isset($_GET['page']) || $_GET['page'] != 'profile-builder-pms-promo'){
new WPPB_Add_General_Notices('wppb_pms_cross_promo',
sprintf(__('Allow your users to have <strong>paid accounts with Profile Builder</strong>. %1$sFind out how >%2$s %3$sDismiss%4$s', 'profile-builder'), "<a href='" . admin_url('options.php?page=profile-builder-pms-promo') . "'>", "</a>", "<a class='wppb-dismiss-notification' href='" . esc_url( add_query_arg('wppb_pms_cross_promo_dismiss_notification', '0') ) . "'>", "</a>"),
'pms-cross-promo');
}
*/

View File

@ -1,252 +1,252 @@
<?php
/**
* Function that creates the "Register your version" submenu page
*
* @since v.2.0
*
* @return void
*/
if( !is_multisite() ){
function wppb_register_your_version_submenu_page()
{
if (PROFILE_BUILDER != 'Profile Builder Free')
add_submenu_page('profile-builder', __('Register Your Version', 'profile-builder'), __('Register Version', 'profile-builder'), 'manage_options', 'profile-builder-register', 'wppb_register_your_version_content');
}
add_action('admin_menu', 'wppb_register_your_version_submenu_page', 20);
}
else{
function wppb_multisite_register_your_version_page()
{
if (PROFILE_BUILDER != 'Profile Builder Free')
add_menu_page(__('Profile Builder Register', 'profile-builder'), __('Profile Builder Register', 'profile-builder'), 'manage_options', 'profile-builder-register', 'wppb_register_your_version_content', WPPB_PLUGIN_URL . 'assets/images/pb-menu-icon.png');
}
add_action('network_admin_menu', 'wppb_multisite_register_your_version_page', 20);
}
/**
* Function that adds content to the "Register your Version" submenu page
*
* @since v.2.0
*
* @return string
*/
function wppb_register_your_version_content() {
?>
<div class="wrap wppb-wrap">
<?php
if ( PROFILE_BUILDER == 'Profile Builder Pro' ){
wppb_serial_form('pro', 'Profile Builder Pro');
}elseif ( PROFILE_BUILDER == 'Profile Builder Hobbyist' ){
wppb_serial_form('hobbyist', 'Profile Builder Hobbyist');
}
?>
</div>
<?php
}
/**
* Function that creates the "Register your version" form depending on Pro or Hobbyist version
*
* @since v.2.0
*
* @return void
*/
function wppb_serial_form($version, $fullname){
?>
<h2><?php _e( "Register your version of $fullname", 'profile-builder' ); ?></h2>
<form method="post" action="<?php echo get_admin_url( 1, 'options.php' ) ?>">
<?php $wppb_profile_builder_serial = get_option( 'wppb_profile_builder_'.$version.'_serial' ); ?>
<?php $wppb_profile_builder_serial_status = get_option( 'wppb_profile_builder_'.$version.'_serial_status' ); ?>
<?php settings_fields( 'wppb_profile_builder_'.$version.'_serial' ); ?>
<p><?php printf( __( "Now that you acquired a copy of %s, you should take the time and register it with the serial number you received", 'profile-builder'), $fullname);?></p>
<p><?php _e( "If you register this version of Profile Builder, you'll receive information regarding upgrades, patches, and technical support.", 'profile-builder' );?></p>
<p class="wppb-serial-wrap">
<label for="wppb_profile_builder_<?php echo $version; ?>_serial"><?php _e(' Serial Number:', 'profile-builder' );?></label>
<input type="password" size="50" name="wppb_profile_builder_<?php echo $version; ?>_serial" id="wppb_profile_builder_<?php echo $version; ?>_serial" class="regular-text" <?php if ( $wppb_profile_builder_serial != ''){ echo ' value="'.$wppb_profile_builder_serial.'"';} ?>/>
<?php
if( $wppb_profile_builder_serial_status == 'found' )
echo '<span class="validateStatus"><img src="'.WPPB_PLUGIN_URL.'/assets/images/accept.png" title="'.__( 'The serial number was successfully validated!', 'profile-builder' ).'"/></span>';
elseif ( $wppb_profile_builder_serial_status == 'notFound' )
echo '<span class="validateStatus"><img src="'.WPPB_PLUGIN_URL.'/assets/images/icon_error.png" title="'.__( 'The serial number entered couldn\'t be validated!','profile-builder' ).'"/></span>';
elseif ( strpos( $wppb_profile_builder_serial_status, 'aboutToExpire') !== false )
echo '<span class="validateStatus"><img src="' . WPPB_PLUGIN_URL . '/assets/images/icon_error.png" title="' . __('The serial number is about to expire soon!', 'profile-builder') . '"/>'. sprintf( __(' Your serial number is about to expire, please %1$s Renew Your License%2$s.','profile-builder'), "<a href='https://www.cozmoslabs.com/downloads/profile-builder-". $version ."-v2-yearly-renewal/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' >", "</a>").'</span>';
elseif ( $wppb_profile_builder_serial_status == 'expired' )
echo '<span class="validateStatus"><img src="'.WPPB_PLUGIN_URL.'/assets/images/icon_error.png" title="'.__( 'The serial number couldn\'t be validated because it expired!','profile-builder' ).'"/>'. sprintf( __(' Your serial number is expired, please %1$s Renew Your License%2$s.','profile-builder'), "<a href='https://www.cozmoslabs.com/downloads/profile-builder-". $version ."-v2-yearly-renewal/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' >", "</a>").'</span>';
elseif ( $wppb_profile_builder_serial_status == 'serverDown' )
echo '<span class="validateStatus"><img src="'.WPPB_PLUGIN_URL.'/assets/images/icon_error.png" title="'.__( 'The serial number couldn\'t be validated because process timed out. This is possible due to the server being down. Please try again later!','profile-builder' ).'"/></span>';
?>
<span class="wppb-serialnumber-descr"><?php _e( '(e.g. RMPB-15-SN-253a55baa4fbe7bf595b2aabb8d72985)', 'profile-builder' );?></span>
</p>
<div id="wppb_submit_button_div">
<input type="hidden" name="action" value="update" />
<p class="submit">
<?php wp_nonce_field( 'wppb_register_version_nonce', 'wppb_register_version_nonce' ); ?>
<input type="submit" name="wppb_serial_number_activate" class="button-primary" value="<?php _e('Save Changes') ?>" />
</p>
</div>
</form>
<?php
}
//the function to check the validity of the serial number and save a variable in the DB; purely visual
function wppb_check_serial_number($oldVal, $newVal){
$serial_number_set = $newVal;
$response = wp_remote_get( 'http://updatemetadata.cozmoslabs.com/checkserial/?serialNumberSent='.$serial_number_set );
if ( PROFILE_BUILDER == 'Profile Builder Pro' ){
wppb_update_serial_status($response, 'pro');
wp_clear_scheduled_hook( "check_plugin_updates-profile-builder-pro-update" );
} else {
wppb_update_serial_status($response, 'hobbyist');
wp_clear_scheduled_hook( "check_plugin_updates-profile-builder-hobbyist-update" );
}
$user_ID = get_current_user_id();
delete_user_meta( $user_ID, 'wppb_dismiss_notification' );
}
add_action( 'update_option_wppb_profile_builder_pro_serial', 'wppb_check_serial_number', 10, 2 );
add_action( 'update_option_wppb_profile_builder_hobbyist_serial', 'wppb_check_serial_number', 10, 2 );
add_action( 'add_option_wppb_profile_builder_pro_serial', 'wppb_check_serial_number', 10, 2 );
add_action( 'add_option_wppb_profile_builder_hobbyist_serial', 'wppb_check_serial_number', 10, 2 );
/**
* @param $response
*/
function wppb_update_serial_status($response, $version)
{
if (is_wp_error($response)) {
update_option('wppb_profile_builder_'.$version.'_serial_status', 'serverDown'); //server down
} elseif ((trim($response['body']) != 'notFound') && (trim($response['body']) != 'found') && (trim($response['body']) != 'expired') && (strpos( $response['body'], 'aboutToExpire' ) === false)) {
update_option('wppb_profile_builder_'.$version.'_serial_status', 'serverDown'); //unknown response parameter
update_option('wppb_profile_builder_'.$version.'_serial', ''); //reset the entered password, since the user will need to try again later
} else {
update_option('wppb_profile_builder_'.$version.'_serial_status', trim($response['body'])); //either found, notFound or expired
}
}
//the update didn't work when the old value = new value, so we need to apply a filter on get_option (that is run before update_option), that resets the old value
function wppb_check_serial_number_fix($newvalue, $oldvalue){
if ( $newvalue == $oldvalue )
wppb_check_serial_number( $oldvalue, $newvalue );
return $newvalue;
}
add_filter( 'pre_update_option_wppb_profile_builder_pro_serial', 'wppb_check_serial_number_fix', 10, 2 );
add_filter( 'pre_update_option_wppb_profile_builder_hobbyist_serial', 'wppb_check_serial_number_fix', 10, 2 );
/**
* Class that adds a notice when either the serial number wasn't found, or it has expired
*
* @since v.2.0
*
* @return void
*/
class wppb_add_notices{
public $pluginPrefix = '';
public $pluginName = '';
public $notificaitonMessage = '';
public $pluginSerialStatus = '';
function __construct( $pluginPrefix, $pluginName, $notificaitonMessage, $pluginSerialStatus ){
$this->pluginPrefix = $pluginPrefix;
$this->pluginName = $pluginName;
$this->notificaitonMessage = $notificaitonMessage;
$this->pluginSerialStatus = $pluginSerialStatus;
add_action( 'admin_notices', array( $this, 'add_admin_notice' ) );
add_action( 'admin_init', array( $this, 'dismiss_notification' ) );
}
// Display a notice that can be dismissed in case the serial number is inactive
function add_admin_notice() {
global $current_user ;
global $pagenow;
$user_id = $current_user->ID;
do_action( $this->pluginPrefix.'_before_notification_displayed', $current_user, $pagenow );
if ( current_user_can( 'manage_options' ) ){
$plugin_serial_status = get_option( $this->pluginSerialStatus );
if ( $plugin_serial_status != 'found' ){
// Check that the user hasn't already clicked to ignore the message
if ( ! get_user_meta($user_id, $this->pluginPrefix.'_dismiss_notification' ) ) {
echo $finalMessage = apply_filters($this->pluginPrefix.'_notification_message','<div class="error wppb-serial-notification" >'.$this->notificaitonMessage.'</div>', $this->notificaitonMessage);
}
}
do_action( $this->pluginPrefix.'_notification_displayed', $current_user, $pagenow, $plugin_serial_status );
}
do_action( $this->pluginPrefix.'_after_notification_displayed', $current_user, $pagenow );
}
function dismiss_notification() {
global $current_user;
$user_id = $current_user->ID;
do_action( $this->pluginPrefix.'_before_notification_dismissed', $current_user );
// If user clicks to ignore the notice, add that to their user meta
if ( isset( $_GET[$this->pluginPrefix.'_dismiss_notification']) && '0' == $_GET[$this->pluginPrefix.'_dismiss_notification'] )
add_user_meta( $user_id, $this->pluginPrefix.'_dismiss_notification', 'true', true );
do_action( $this->pluginPrefix.'_after_notification_dismissed', $current_user );
}
}
if( is_multisite() && function_exists( 'switch_to_blog' ) )
switch_to_blog(1);
if ( PROFILE_BUILDER == 'Profile Builder Pro' ){
$wppb_profile_builder_pro_hobbyist_serial_status = get_option( 'wppb_profile_builder_pro_serial_status', 'empty' );
$version = 'pro';
} elseif( PROFILE_BUILDER == 'Profile Builder Hobbyist' ) {
$wppb_profile_builder_pro_hobbyist_serial_status = get_option( 'wppb_profile_builder_hobbyist_serial_status', 'empty' );
$version = 'hobbyist';
}
if( is_multisite() && function_exists( 'restore_current_blog' ) )
restore_current_blog();
if ( $wppb_profile_builder_pro_hobbyist_serial_status == 'notFound' || $wppb_profile_builder_pro_hobbyist_serial_status == 'empty' ){
if( !is_multisite() )
$register_url = 'admin.php?page=profile-builder-register';
else
$register_url = network_admin_url( 'admin.php?page=profile-builder-register' );
new wppb_add_notices( 'wppb', 'profile_builder_pro', sprintf( __( '<p>Your <strong>Profile Builder</strong> serial number is invalid or missing. <br/>Please %1$sregister your copy%2$s to receive access to automatic updates and support. Need a license key? %3$sPurchase one now%4$s</p>', 'profile-builder'), "<a href='". $register_url ."'>", "</a>", "<a href='https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-SN-Purchase' target='_blank' class='button-primary'>", "</a>" ), 'wppb_profile_builder_pro_serial_status' );
}
elseif ( $wppb_profile_builder_pro_hobbyist_serial_status == 'expired' ){
new wppb_add_notices( 'wppb_expired', 'profile_builder_pro', sprintf( __( '<p>Your <strong>Profile Builder</strong> license has expired. <br/>Please %1$sRenew Your Licence%2$s to continue receiving access to product downloads, automatic updates and support. %3$sRenew now and get 40&#37; off %4$s %5$sDismiss%6$s</p>', 'profile-builder'), "<a href='https://www.cozmoslabs.com/downloads/profile-builder-". $version ."-v2-yearly-renewal/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' target='_blank'>", "</a>", "<a href='https://www.cozmoslabs.com/downloads/profile-builder-".$version."-v2-yearly-renewal/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' target='_blank' class='button-primary'>", "</a>", "<a href='". esc_url( add_query_arg( 'wppb_expired_dismiss_notification', '0' ) ) ."' class='wppb-dismiss-notification'>", "</a>" ), 'wppb_profile_builder_pro_serial_status' );
}
elseif( strpos( $wppb_profile_builder_pro_hobbyist_serial_status, 'aboutToExpire' ) === 0 ){
$serial_status_parts = explode( '#', $wppb_profile_builder_pro_hobbyist_serial_status );
$date = $serial_status_parts[1];
new wppb_add_notices( 'wppb_about_to_expire', 'profile_builder_pro', sprintf( __( '<p>Your <strong>Profile Builder</strong> license is about to expire on %5$s. <br/>Please %1$sRenew Your Licence%2$s to continue receiving access to product downloads, automatic updates and support. %3$sRenew now and get 40&#37; off %4$s %6$sDismiss%7$s</p>', 'profile-builder'), "<a href='https://www.cozmoslabs.com/downloads/profile-builder-". $version ."-v2-yearly-renewal/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' target='_blank'>", "</a>", "<a href='https://www.cozmoslabs.com/downloads/profile-builder-".$version."-v2-yearly-renewal/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' target='_blank' class='button-primary'>", "</a>", $date, "<a href='". esc_url( add_query_arg( 'wppb_about_to_expire_dismiss_notification', '0' ) )."' class='wppb-dismiss-notification'>", "</a>" ), 'wppb_profile_builder_pro_serial_status' );
<?php
/**
* Function that creates the "Register your version" submenu page
*
* @since v.2.0
*
* @return void
*/
if( !is_multisite() ){
function wppb_register_your_version_submenu_page()
{
if (PROFILE_BUILDER != 'Profile Builder Free')
add_submenu_page('profile-builder', __('Register Your Version', 'profile-builder'), __('Register Version', 'profile-builder'), 'manage_options', 'profile-builder-register', 'wppb_register_your_version_content');
}
add_action('admin_menu', 'wppb_register_your_version_submenu_page', 20);
}
else{
function wppb_multisite_register_your_version_page()
{
if (PROFILE_BUILDER != 'Profile Builder Free')
add_menu_page(__('Profile Builder Register', 'profile-builder'), __('Profile Builder Register', 'profile-builder'), 'manage_options', 'profile-builder-register', 'wppb_register_your_version_content', WPPB_PLUGIN_URL . 'assets/images/pb-menu-icon.png');
}
add_action('network_admin_menu', 'wppb_multisite_register_your_version_page', 20);
}
/**
* Function that adds content to the "Register your Version" submenu page
*
* @since v.2.0
*
* @return string
*/
function wppb_register_your_version_content() {
?>
<div class="wrap wppb-wrap">
<?php
if ( PROFILE_BUILDER == 'Profile Builder Pro' ){
wppb_serial_form('pro', 'Profile Builder Pro');
}elseif ( PROFILE_BUILDER == 'Profile Builder Hobbyist' ){
wppb_serial_form('hobbyist', 'Profile Builder Hobbyist');
}
?>
</div>
<?php
}
/**
* Function that creates the "Register your version" form depending on Pro or Hobbyist version
*
* @since v.2.0
*
* @return void
*/
function wppb_serial_form($version, $fullname){
?>
<h2><?php _e( "Register your version of $fullname", 'profile-builder' ); ?></h2>
<form method="post" action="<?php echo get_admin_url( 1, 'options.php' ) ?>">
<?php $wppb_profile_builder_serial = get_option( 'wppb_profile_builder_'.$version.'_serial' ); ?>
<?php $wppb_profile_builder_serial_status = get_option( 'wppb_profile_builder_'.$version.'_serial_status' ); ?>
<?php settings_fields( 'wppb_profile_builder_'.$version.'_serial' ); ?>
<p><?php printf( __( "Now that you acquired a copy of %s, you should take the time and register it with the serial number you received", 'profile-builder'), $fullname);?></p>
<p><?php _e( "If you register this version of Profile Builder, you'll receive information regarding upgrades, patches, and technical support.", 'profile-builder' );?></p>
<p class="wppb-serial-wrap">
<label for="wppb_profile_builder_<?php echo $version; ?>_serial"><?php _e(' Serial Number:', 'profile-builder' );?></label>
<input type="password" size="50" name="wppb_profile_builder_<?php echo $version; ?>_serial" id="wppb_profile_builder_<?php echo $version; ?>_serial" class="regular-text" <?php if ( $wppb_profile_builder_serial != ''){ echo ' value="'.$wppb_profile_builder_serial.'"';} ?>/>
<?php
if( $wppb_profile_builder_serial_status == 'found' )
echo '<span class="validateStatus"><img src="'.WPPB_PLUGIN_URL.'/assets/images/accept.png" title="'.__( 'The serial number was successfully validated!', 'profile-builder' ).'"/></span>';
elseif ( $wppb_profile_builder_serial_status == 'notFound' )
echo '<span class="validateStatus"><img src="'.WPPB_PLUGIN_URL.'/assets/images/icon_error.png" title="'.__( 'The serial number entered couldn\'t be validated!','profile-builder' ).'"/></span>';
elseif ( strpos( $wppb_profile_builder_serial_status, 'aboutToExpire') !== false )
echo '<span class="validateStatus"><img src="' . WPPB_PLUGIN_URL . '/assets/images/icon_error.png" title="' . __('The serial number is about to expire soon!', 'profile-builder') . '"/>'. sprintf( __(' Your serial number is about to expire, please %1$s Renew Your License%2$s.','profile-builder'), "<a href='https://www.cozmoslabs.com/downloads/profile-builder-". $version ."-v2-yearly-renewal/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' >", "</a>").'</span>';
elseif ( $wppb_profile_builder_serial_status == 'expired' )
echo '<span class="validateStatus"><img src="'.WPPB_PLUGIN_URL.'/assets/images/icon_error.png" title="'.__( 'The serial number couldn\'t be validated because it expired!','profile-builder' ).'"/>'. sprintf( __(' Your serial number is expired, please %1$s Renew Your License%2$s.','profile-builder'), "<a href='https://www.cozmoslabs.com/downloads/profile-builder-". $version ."-v2-yearly-renewal/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' >", "</a>").'</span>';
elseif ( $wppb_profile_builder_serial_status == 'serverDown' )
echo '<span class="validateStatus"><img src="'.WPPB_PLUGIN_URL.'/assets/images/icon_error.png" title="'.__( 'The serial number couldn\'t be validated because process timed out. This is possible due to the server being down. Please try again later!','profile-builder' ).'"/></span>';
?>
<span class="wppb-serialnumber-descr"><?php _e( '(e.g. RMPB-15-SN-253a55baa4fbe7bf595b2aabb8d72985)', 'profile-builder' );?></span>
</p>
<div id="wppb_submit_button_div">
<input type="hidden" name="action" value="update" />
<p class="submit">
<?php wp_nonce_field( 'wppb_register_version_nonce', 'wppb_register_version_nonce' ); ?>
<input type="submit" name="wppb_serial_number_activate" class="button-primary" value="<?php _e('Save Changes') ?>" />
</p>
</div>
</form>
<?php
}
//the function to check the validity of the serial number and save a variable in the DB; purely visual
function wppb_check_serial_number($oldVal, $newVal){
$serial_number_set = $newVal;
$response = wp_remote_get( 'http://updatemetadata.cozmoslabs.com/checkserial/?serialNumberSent='.$serial_number_set );
if ( PROFILE_BUILDER == 'Profile Builder Pro' ){
wppb_update_serial_status($response, 'pro');
wp_clear_scheduled_hook( "check_plugin_updates-profile-builder-pro-update" );
} else {
wppb_update_serial_status($response, 'hobbyist');
wp_clear_scheduled_hook( "check_plugin_updates-profile-builder-hobbyist-update" );
}
$user_ID = get_current_user_id();
delete_user_meta( $user_ID, 'wppb_dismiss_notification' );
}
add_action( 'update_option_wppb_profile_builder_pro_serial', 'wppb_check_serial_number', 10, 2 );
add_action( 'update_option_wppb_profile_builder_hobbyist_serial', 'wppb_check_serial_number', 10, 2 );
add_action( 'add_option_wppb_profile_builder_pro_serial', 'wppb_check_serial_number', 10, 2 );
add_action( 'add_option_wppb_profile_builder_hobbyist_serial', 'wppb_check_serial_number', 10, 2 );
/**
* @param $response
*/
function wppb_update_serial_status($response, $version)
{
if (is_wp_error($response)) {
update_option('wppb_profile_builder_'.$version.'_serial_status', 'serverDown'); //server down
} elseif ((trim($response['body']) != 'notFound') && (trim($response['body']) != 'found') && (trim($response['body']) != 'expired') && (strpos( $response['body'], 'aboutToExpire' ) === false)) {
update_option('wppb_profile_builder_'.$version.'_serial_status', 'serverDown'); //unknown response parameter
update_option('wppb_profile_builder_'.$version.'_serial', ''); //reset the entered password, since the user will need to try again later
} else {
update_option('wppb_profile_builder_'.$version.'_serial_status', trim($response['body'])); //either found, notFound or expired
}
}
//the update didn't work when the old value = new value, so we need to apply a filter on get_option (that is run before update_option), that resets the old value
function wppb_check_serial_number_fix($newvalue, $oldvalue){
if ( $newvalue == $oldvalue )
wppb_check_serial_number( $oldvalue, $newvalue );
return $newvalue;
}
add_filter( 'pre_update_option_wppb_profile_builder_pro_serial', 'wppb_check_serial_number_fix', 10, 2 );
add_filter( 'pre_update_option_wppb_profile_builder_hobbyist_serial', 'wppb_check_serial_number_fix', 10, 2 );
/**
* Class that adds a notice when either the serial number wasn't found, or it has expired
*
* @since v.2.0
*
* @return void
*/
class wppb_add_notices{
public $pluginPrefix = '';
public $pluginName = '';
public $notificaitonMessage = '';
public $pluginSerialStatus = '';
function __construct( $pluginPrefix, $pluginName, $notificaitonMessage, $pluginSerialStatus ){
$this->pluginPrefix = $pluginPrefix;
$this->pluginName = $pluginName;
$this->notificaitonMessage = $notificaitonMessage;
$this->pluginSerialStatus = $pluginSerialStatus;
add_action( 'admin_notices', array( $this, 'add_admin_notice' ) );
add_action( 'admin_init', array( $this, 'dismiss_notification' ) );
}
// Display a notice that can be dismissed in case the serial number is inactive
function add_admin_notice() {
global $current_user ;
global $pagenow;
$user_id = $current_user->ID;
do_action( $this->pluginPrefix.'_before_notification_displayed', $current_user, $pagenow );
if ( current_user_can( 'manage_options' ) ){
$plugin_serial_status = get_option( $this->pluginSerialStatus );
if ( $plugin_serial_status != 'found' ){
// Check that the user hasn't already clicked to ignore the message
if ( ! get_user_meta($user_id, $this->pluginPrefix.'_dismiss_notification' ) ) {
echo $finalMessage = apply_filters($this->pluginPrefix.'_notification_message','<div class="error wppb-serial-notification" >'.$this->notificaitonMessage.'</div>', $this->notificaitonMessage);
}
}
do_action( $this->pluginPrefix.'_notification_displayed', $current_user, $pagenow, $plugin_serial_status );
}
do_action( $this->pluginPrefix.'_after_notification_displayed', $current_user, $pagenow );
}
function dismiss_notification() {
global $current_user;
$user_id = $current_user->ID;
do_action( $this->pluginPrefix.'_before_notification_dismissed', $current_user );
// If user clicks to ignore the notice, add that to their user meta
if ( isset( $_GET[$this->pluginPrefix.'_dismiss_notification']) && '0' == $_GET[$this->pluginPrefix.'_dismiss_notification'] )
add_user_meta( $user_id, $this->pluginPrefix.'_dismiss_notification', 'true', true );
do_action( $this->pluginPrefix.'_after_notification_dismissed', $current_user );
}
}
if( is_multisite() && function_exists( 'switch_to_blog' ) )
switch_to_blog(1);
if ( PROFILE_BUILDER == 'Profile Builder Pro' ){
$wppb_profile_builder_pro_hobbyist_serial_status = get_option( 'wppb_profile_builder_pro_serial_status', 'empty' );
$version = 'pro';
} elseif( PROFILE_BUILDER == 'Profile Builder Hobbyist' ) {
$wppb_profile_builder_pro_hobbyist_serial_status = get_option( 'wppb_profile_builder_hobbyist_serial_status', 'empty' );
$version = 'hobbyist';
}
if( is_multisite() && function_exists( 'restore_current_blog' ) )
restore_current_blog();
if ( $wppb_profile_builder_pro_hobbyist_serial_status == 'notFound' || $wppb_profile_builder_pro_hobbyist_serial_status == 'empty' ){
if( !is_multisite() )
$register_url = 'admin.php?page=profile-builder-register';
else
$register_url = network_admin_url( 'admin.php?page=profile-builder-register' );
new wppb_add_notices( 'wppb', 'profile_builder_pro', sprintf( __( '<p>Your <strong>Profile Builder</strong> serial number is invalid or missing. <br/>Please %1$sregister your copy%2$s to receive access to automatic updates and support. Need a license key? %3$sPurchase one now%4$s</p>', 'profile-builder'), "<a href='". $register_url ."'>", "</a>", "<a href='https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-SN-Purchase' target='_blank' class='button-primary'>", "</a>" ), 'wppb_profile_builder_pro_serial_status' );
}
elseif ( $wppb_profile_builder_pro_hobbyist_serial_status == 'expired' ){
new wppb_add_notices( 'wppb_expired', 'profile_builder_pro', sprintf( __( '<p>Your <strong>Profile Builder</strong> license has expired. <br/>Please %1$sRenew Your Licence%2$s to continue receiving access to product downloads, automatic updates and support. %3$sRenew now and get 40&#37; off %4$s %5$sDismiss%6$s</p>', 'profile-builder'), "<a href='https://www.cozmoslabs.com/downloads/profile-builder-". $version ."-v2-yearly-renewal/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' target='_blank'>", "</a>", "<a href='https://www.cozmoslabs.com/downloads/profile-builder-".$version."-v2-yearly-renewal/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' target='_blank' class='button-primary'>", "</a>", "<a href='". esc_url( add_query_arg( 'wppb_expired_dismiss_notification', '0' ) ) ."' class='wppb-dismiss-notification'>", "</a>" ), 'wppb_profile_builder_pro_serial_status' );
}
elseif( strpos( $wppb_profile_builder_pro_hobbyist_serial_status, 'aboutToExpire' ) === 0 ){
$serial_status_parts = explode( '#', $wppb_profile_builder_pro_hobbyist_serial_status );
$date = $serial_status_parts[1];
new wppb_add_notices( 'wppb_about_to_expire', 'profile_builder_pro', sprintf( __( '<p>Your <strong>Profile Builder</strong> license is about to expire on %5$s. <br/>Please %1$sRenew Your Licence%2$s to continue receiving access to product downloads, automatic updates and support. %3$sRenew now and get 40&#37; off %4$s %6$sDismiss%7$s</p>', 'profile-builder'), "<a href='https://www.cozmoslabs.com/downloads/profile-builder-". $version ."-v2-yearly-renewal/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' target='_blank'>", "</a>", "<a href='https://www.cozmoslabs.com/downloads/profile-builder-".$version."-v2-yearly-renewal/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' target='_blank' class='button-primary'>", "</a>", $date, "<a href='". esc_url( add_query_arg( 'wppb_about_to_expire_dismiss_notification', '0' ) )."' class='wppb-dismiss-notification'>", "</a>" ), 'wppb_profile_builder_pro_serial_status' );
}

View File

@ -1,60 +1,60 @@
.wppb-user-forms .wppb-wysiwyg .wp-editor-wrap {
float:right;
}
#wppb-search-fields{
float:right;
}
.wppb-form-field label,
#wppb-login-wrap .login-username label,
#wppb-login-wrap .login-password label{
float:right;
}
.wppb-form-field input,
.wppb-form-field input[type="text"], .wppb-form-field input[type="email"], .wppb-form-field input[type="url"], .wppb-form-field input[type="password"], .wppb-form-field input[type="search"],
.wppb-form-field select,
.wppb-form-field textarea,
.wppb-checkboxes,
.wppb-radios,
#wppb-login-wrap .login-username input,
#wppb-login-wrap .login-password input{
float:right;
}
.wppb-table th{
text-align: right;
}
ul.wppb-profile li label{
float:right;
}
ul.wppb-profile li span{
float:right;
}
@media screen and ( max-width: 720px ) {
.wppb-table td {
text-align: right;
}
.wppb-table .wppb-posts,
.wppb-table .wppb-moreinfo{
text-align: left;
}
.wppb-table td:before {
float: right;
}
}
@media screen and (max-width: 400px) {
.wppb-form-field input,
.wppb-form-field select,
.wppb-form-field textarea,
.wppb-checkboxes,
.wppb-radios,
#wppb-login-wrap .login-username input,
#wppb-login-wrap .login-password input,
ul.wppb-profile li span{
float:right;
}
}
#pass-strength-result {
float: right;
.wppb-user-forms .wppb-wysiwyg .wp-editor-wrap {
float:right;
}
#wppb-search-fields{
float:right;
}
.wppb-form-field label,
#wppb-login-wrap .login-username label,
#wppb-login-wrap .login-password label{
float:right;
}
.wppb-form-field input,
.wppb-form-field input[type="text"], .wppb-form-field input[type="email"], .wppb-form-field input[type="url"], .wppb-form-field input[type="password"], .wppb-form-field input[type="search"],
.wppb-form-field select,
.wppb-form-field textarea,
.wppb-checkboxes,
.wppb-radios,
#wppb-login-wrap .login-username input,
#wppb-login-wrap .login-password input{
float:right;
}
.wppb-table th{
text-align: right;
}
ul.wppb-profile li label{
float:right;
}
ul.wppb-profile li span{
float:right;
}
@media screen and ( max-width: 720px ) {
.wppb-table td {
text-align: right;
}
.wppb-table .wppb-posts,
.wppb-table .wppb-moreinfo{
text-align: left;
}
.wppb-table td:before {
float: right;
}
}
@media screen and (max-width: 400px) {
.wppb-form-field input,
.wppb-form-field select,
.wppb-form-field textarea,
.wppb-checkboxes,
.wppb-radios,
#wppb-login-wrap .login-username input,
#wppb-login-wrap .login-password input,
ul.wppb-profile li span{
float:right;
}
}
#pass-strength-result {
float: right;
}

File diff suppressed because one or more lines are too long

View File

@ -1,44 +1,44 @@
.wppb-serial-wrap{
margin:40px 0;
}
.wppb-dismiss-notification{
position:absolute;
right:0px;
top:50%;
margin-top:-7px;
}
.pms-cross-promo .wppb-dismiss-notification{
right: 10px;
margin-top:-10px;
}
div.wppb-serial-notification p{
padding-right: 50px;
position:relative;
}
.pms-cross-promo{
position: relative;
background-color: #fff;
border-left: 4px solid #d54e21;
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
display: block;
font-size: 14px;
line-height: 19px;
margin: 35px 20px 0 2px;
padding: 11px 15px;
text-align: left;
color: #fff;
background: #5693d3;
}
.pms-cross-promo a{
padding: 0 3px;
color:#fff;
border-radius: 2px;
}
.pms-cross-promo a:hover{
background: #fff;
color: #5693d3;
text-decoration: none;
}
.wppb-serial-wrap{
margin:40px 0;
}
.wppb-dismiss-notification{
position:absolute;
right:0px;
top:50%;
margin-top:-7px;
}
.pms-cross-promo .wppb-dismiss-notification{
right: 10px;
margin-top:-10px;
}
div.wppb-serial-notification p{
padding-right: 50px;
position:relative;
}
.pms-cross-promo{
position: relative;
background-color: #fff;
border-left: 4px solid #d54e21;
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
display: block;
font-size: 14px;
line-height: 19px;
margin: 35px 20px 0 2px;
padding: 11px 15px;
text-align: left;
color: #fff;
background: #5693d3;
}
.pms-cross-promo a{
padding: 0 3px;
color:#fff;
border-radius: 2px;
}
.pms-cross-promo a:hover{
background: #fff;
color: #5693d3;
text-decoration: none;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +1,16 @@
function confirmDelete( nonceField, currentUser, customFieldID, customFieldName, returnTo, ajaxurl, what, fileName, text ) {
if (confirm(text)) {
jQuery.post( ajaxurl , { action:"hook_wppb_delete", currentUser:currentUser, customFieldID:customFieldID, customFieldName:customFieldName, what:what, _ajax_nonce:nonceField }, function( response ) {
if( jQuery.trim(response)=="done" ){
if ( what == 'avatar' ){
alert( ep.avatar );
}else{
alert( ep.attachment +' '+ fileName );
}
window.location=returnTo;
}else{
alert(jQuery.trim(response));
}
});
}
function confirmDelete( nonceField, currentUser, customFieldID, customFieldName, returnTo, ajaxurl, what, fileName, text ) {
if (confirm(text)) {
jQuery.post( ajaxurl , { action:"hook_wppb_delete", currentUser:currentUser, customFieldID:customFieldID, customFieldName:customFieldName, what:what, _ajax_nonce:nonceField }, function( response ) {
if( jQuery.trim(response)=="done" ){
if ( what == 'avatar' ){
alert( ep.avatar );
}else{
alert( ep.attachment +' '+ fileName );
}
window.location=returnTo;
}else{
alert(jQuery.trim(response));
}
});
}
}

View File

@ -1,53 +1,53 @@
function wppb_display_page_select( value ){
if ( value == 'yes' ){
jQuery ( '#wppb-settings-activation-page' ).show();
jQuery ( '.dynamic1' ).show();
}else{
jQuery ( '#wppb-settings-activation-page' ).hide();
jQuery ( '.dynamic1' ).hide();
}
}
function wppb_display_page_select_aa( value ){
if ( value == 'yes' )
jQuery ( '.dynamic2' ).show();
else
jQuery ( '.dynamic2' ).hide();
}
function wppb_display_page_select_re( value ){
if ( value == 'yes' )
jQuery ( '.dynamic3' ).show();
else
jQuery ( '.dynamic3' ).hide();
}
jQuery(function() {
if ( ( jQuery( '#wppb_settings_email_confirmation' ).val() == 'yes' ) || ( jQuery( '#wppb_general_settings_hidden' ).val() == 'multisite' ) ){
jQuery ( '#wppb-settings-activation-page' ).show();
jQuery ( '.dynamic1' ).show();
}else{
jQuery ( '#wppb-settings-activation-page' ).hide();
jQuery ( '.dynamic1' ).hide();
}
if ( jQuery( '#adminApprovalSelect' ).val() == 'yes' )
jQuery ( '.dynamic2' ).show();
else
jQuery ( '.dynamic2' ).hide();
if ( jQuery( '#rolesEditorSelect' ).val() == 'yes' )
jQuery ( '.dynamic3' ).show();
else
jQuery ( '.dynamic3' ).hide();
function wppb_display_page_select( value ){
if ( value == 'yes' ){
jQuery ( '#wppb-settings-activation-page' ).show();
jQuery ( '.dynamic1' ).show();
}else{
jQuery ( '#wppb-settings-activation-page' ).hide();
jQuery ( '.dynamic1' ).hide();
}
}
function wppb_display_page_select_aa( value ){
if ( value == 'yes' )
jQuery ( '.dynamic2' ).show();
else
jQuery ( '.dynamic2' ).hide();
}
function wppb_display_page_select_re( value ){
if ( value == 'yes' )
jQuery ( '.dynamic3' ).show();
else
jQuery ( '.dynamic3' ).hide();
}
jQuery(function() {
if ( ( jQuery( '#wppb_settings_email_confirmation' ).val() == 'yes' ) || ( jQuery( '#wppb_general_settings_hidden' ).val() == 'multisite' ) ){
jQuery ( '#wppb-settings-activation-page' ).show();
jQuery ( '.dynamic1' ).show();
}else{
jQuery ( '#wppb-settings-activation-page' ).hide();
jQuery ( '.dynamic1' ).hide();
}
if ( jQuery( '#adminApprovalSelect' ).val() == 'yes' )
jQuery ( '.dynamic2' ).show();
else
jQuery ( '.dynamic2' ).hide();
if ( jQuery( '#rolesEditorSelect' ).val() == 'yes' )
jQuery ( '.dynamic3' ).show();
else
jQuery ( '.dynamic3' ).hide();
});

View File

@ -1,166 +1,166 @@
function wppb_epf_rf_disable_live_select ( selector ){
jQuery( selector ).attr( 'disabled', true );
}
function wppb_rf_epf_change_id( field, container_name, fieldObj ) {
var buttonInContainer = jQuery( '.button-primary', fieldObj.parent().parent().parent() );
buttonInContainer.attr('disabled',true);
buttonInContainer.attr('tempclick', buttonInContainer.attr("onclick") );
buttonInContainer.removeAttr('onclick');
jQuery.post( ajaxurl , { action:"wppb_handle_rf_epf_id_change", field:field }, function(response) {
/**
* since version 2.0.2 we have the id directly on the option in the select so this ajax function is a little
redundant but can't be sure of the impact on other features so we will just add this
*/
id = fieldObj.find(":selected").attr( 'data-id' );
if( !id ){
id = response;
}
jQuery( '#id', fieldObj.parent().parent().parent() ).val( id );
buttonInContainer.attr('onclick', buttonInContainer.attr("tempclick") );
buttonInContainer.removeAttr('tempclick');
if( ( fieldObj.parents('.update_container_wppb_rf_fields').length || fieldObj.parents('.update_container_wppb_epf_fields').length ) && buttonInContainer.attr('disabled') ) {
buttonInContainer.text('Save Changes');
}
buttonInContainer.removeAttr('disabled');
});
}
jQuery(function(){
wppb_disable_delete_on_default_mandatory_fields();
wppb_disable_select_field_options();
jQuery(document).on( 'change', '#wppb_rf_fields .mb-list-entry-fields #field', function () {
wppb_rf_epf_change_id( jQuery(this).val(), '#wppb_rf_fields', jQuery(this) );
});
jQuery(document).on( 'change', '.update_container_wppb_rf_fields .mb-list-entry-fields #field', function () {
wppb_rf_epf_change_id( jQuery(this).val(), '.update_container_wppb_rf_fields', jQuery(this) );
});
jQuery(document).on( 'change', '#wppb_epf_fields .mb-list-entry-fields #field', function () {
wppb_rf_epf_change_id( jQuery(this).val(), '#wppb_epf_fields', jQuery(this) );
});
jQuery(document).on( 'change', '.update_container_wppb_epf_fields .mb-list-entry-fields #field', function () {
wppb_rf_epf_change_id( jQuery(this).val(), '.update_container_wppb_epf_fields', jQuery(this) );
});
});
/* function that removes the delete button and disables changing the field type on edit for username,password and email default fields */
function wppb_disable_delete_on_default_mandatory_fields(){
jQuery( '#container_wppb_rf_fields [class$="default-username added_fields_list"] .mbdelete, #container_wppb_rf_fields [class$="default-e-mail added_fields_list"] .mbdelete, #container_wppb_rf_fields [class$="default-password added_fields_list"] .mbdelete' ).hide(); // PB specific line
jQuery( '[class$="default-username"] #field, [class$="default-e-mail"] #field, [class$="default-password"] #field' ).attr( 'disabled', true ); // PB specific line
}
/* Disables the options in the field select drop-down that are also present in the table below */
function wppb_disable_select_field_options() {
jQuery('#field option').each( function() {
$optionField = jQuery(this);
$optionField.removeAttr('disabled');
var optionFieldId = jQuery(this).attr('data-id');
jQuery('#container_wppb_rf_fields .row-id pre, #container_wppb_epf_fields .row-id pre').each( function() {
if( jQuery(this).text() == optionFieldId ) {
$optionField.attr('disabled', true);
}
});
});
wppb_check_options_disabled_add_field();
}
/*
* Check to see if the selected field in the add new field to the list select drop-down is disabled
* We don't want this to happen, so select the first option instead
*/
function wppb_check_options_disabled_add_field() {
if( jQuery('#wppb_rf_fields #field option:selected, #wppb_epf_fields #field option:selected').is(':disabled') ) {
jQuery('#wppb_rf_fields #field option, #wppb_epf_fields #field option').first().attr('selected', true);
}
}
/*
* Run through all the field drop-downs, in edit mode, and check if the selected option is disabled
* If it is, disable the save button and if the date-id of the selected option matches the id of the field
* change the text of the button
*/
function wppb_check_options_disabled_edit_field() {
jQuery('.update_container_wppb_rf_fields #field, .update_container_wppb_epf_fields #field').each( function() {
$selectedOption = jQuery(this).children('option:selected');
$primaryButton = jQuery(this).parents('.mb-list-entry-fields').find('.button-primary');
if( $selectedOption.is(':disabled') ) {
$rowId = parseInt( jQuery(this).parents('tr').prev().find('.row-id pre').text() );
$primaryButton.attr('disabled', true);
$primaryButton[0].onclick = null;
if( $rowId != parseInt( $selectedOption.attr('data-id') ) ) {
$primaryButton.text('This field has already been added to the form');
}
} else {
$primaryButton.attr('disabled', false);
var tempBtnOnClick = $primaryButton.attr('onclick');
$primaryButton.text('Save Changes').removeAttr('onclick').attr('onclick', tempBtnOnClick);
}
});
}
/*
* Check to see if the selected field in the edit field select drop-down is disabled
* If it is we want to disable saving, because no changes have been made
*/
function wppb_check_update_field_options_disabled() {
jQuery('.update_container_wppb_rf_fields #field, .update_container_wppb_epf_fields #field').each( function() {
if( jQuery(this).find('option:selected').is(':disabled') ) {
jQuery(this).parents('.mb-list-entry-fields').find('.button-primary').attr('disabled', true);
jQuery(this).parents('.mb-list-entry-fields').find('.button-primary')[0].onclick = null;
}
});
}
/*
* Function that sends an ajax request to delete all items(fields) from a form
*
*/
function wppb_rf_epf_delete_all_fields(event, delete_all_button_id, nonce) {
event.preventDefault();
$deleteButton = jQuery('#' + delete_all_button_id);
var response = confirm( "Are you sure you want to delete all items ?" );
if( response == true ) {
$tableParent = $deleteButton.parents('table');
var meta = $tableParent.attr('id').replace('container_', '');
var post_id = parseInt( $tableParent.attr('post') );
$tableParent.parent().css({'opacity':'0.4', 'position':'relative'}).append('<div id="mb-ajax-loading"></div>');
jQuery.post( ajaxurl, { action: "wppb_rf_epf_delete_all_fields", meta: meta, id: post_id, _ajax_nonce: nonce }, function(response) {
/* refresh the list */
jQuery.post( wppbWckAjaxurl, { action: "wck_refresh_list"+meta, meta: meta, id: post_id}, function(response) {
jQuery('#container_'+meta).replaceWith(response);
$tableParent = jQuery('#container_'+meta);
$tableParent.find('tbody td').css('width', function(){ return jQuery(this).width() });
mb_sortable_elements();
$tableParent.parent().css('opacity','1');
jQuery('#mb-ajax-loading').remove();
});
});
}
function wppb_epf_rf_disable_live_select ( selector ){
jQuery( selector ).attr( 'disabled', true );
}
function wppb_rf_epf_change_id( field, container_name, fieldObj ) {
var buttonInContainer = jQuery( '.button-primary', fieldObj.parent().parent().parent() );
buttonInContainer.attr('disabled',true);
buttonInContainer.attr('tempclick', buttonInContainer.attr("onclick") );
buttonInContainer.removeAttr('onclick');
jQuery.post( ajaxurl , { action:"wppb_handle_rf_epf_id_change", field:field }, function(response) {
/**
* since version 2.0.2 we have the id directly on the option in the select so this ajax function is a little
redundant but can't be sure of the impact on other features so we will just add this
*/
id = fieldObj.find(":selected").attr( 'data-id' );
if( !id ){
id = response;
}
jQuery( '#id', fieldObj.parent().parent().parent() ).val( id );
buttonInContainer.attr('onclick', buttonInContainer.attr("tempclick") );
buttonInContainer.removeAttr('tempclick');
if( ( fieldObj.parents('.update_container_wppb_rf_fields').length || fieldObj.parents('.update_container_wppb_epf_fields').length ) && buttonInContainer.attr('disabled') ) {
buttonInContainer.text('Save Changes');
}
buttonInContainer.removeAttr('disabled');
});
}
jQuery(function(){
wppb_disable_delete_on_default_mandatory_fields();
wppb_disable_select_field_options();
jQuery(document).on( 'change', '#wppb_rf_fields .mb-list-entry-fields #field', function () {
wppb_rf_epf_change_id( jQuery(this).val(), '#wppb_rf_fields', jQuery(this) );
});
jQuery(document).on( 'change', '.update_container_wppb_rf_fields .mb-list-entry-fields #field', function () {
wppb_rf_epf_change_id( jQuery(this).val(), '.update_container_wppb_rf_fields', jQuery(this) );
});
jQuery(document).on( 'change', '#wppb_epf_fields .mb-list-entry-fields #field', function () {
wppb_rf_epf_change_id( jQuery(this).val(), '#wppb_epf_fields', jQuery(this) );
});
jQuery(document).on( 'change', '.update_container_wppb_epf_fields .mb-list-entry-fields #field', function () {
wppb_rf_epf_change_id( jQuery(this).val(), '.update_container_wppb_epf_fields', jQuery(this) );
});
});
/* function that removes the delete button and disables changing the field type on edit for username,password and email default fields */
function wppb_disable_delete_on_default_mandatory_fields(){
jQuery( '#container_wppb_rf_fields [class$="default-username added_fields_list"] .mbdelete, #container_wppb_rf_fields [class$="default-e-mail added_fields_list"] .mbdelete, #container_wppb_rf_fields [class$="default-password added_fields_list"] .mbdelete' ).hide(); // PB specific line
jQuery( '[class$="default-username"] #field, [class$="default-e-mail"] #field, [class$="default-password"] #field' ).attr( 'disabled', true ); // PB specific line
}
/* Disables the options in the field select drop-down that are also present in the table below */
function wppb_disable_select_field_options() {
jQuery('#field option').each( function() {
$optionField = jQuery(this);
$optionField.removeAttr('disabled');
var optionFieldId = jQuery(this).attr('data-id');
jQuery('#container_wppb_rf_fields .row-id pre, #container_wppb_epf_fields .row-id pre').each( function() {
if( jQuery(this).text() == optionFieldId ) {
$optionField.attr('disabled', true);
}
});
});
wppb_check_options_disabled_add_field();
}
/*
* Check to see if the selected field in the add new field to the list select drop-down is disabled
* We don't want this to happen, so select the first option instead
*/
function wppb_check_options_disabled_add_field() {
if( jQuery('#wppb_rf_fields #field option:selected, #wppb_epf_fields #field option:selected').is(':disabled') ) {
jQuery('#wppb_rf_fields #field option, #wppb_epf_fields #field option').first().attr('selected', true);
}
}
/*
* Run through all the field drop-downs, in edit mode, and check if the selected option is disabled
* If it is, disable the save button and if the date-id of the selected option matches the id of the field
* change the text of the button
*/
function wppb_check_options_disabled_edit_field() {
jQuery('.update_container_wppb_rf_fields #field, .update_container_wppb_epf_fields #field').each( function() {
$selectedOption = jQuery(this).children('option:selected');
$primaryButton = jQuery(this).parents('.mb-list-entry-fields').find('.button-primary');
if( $selectedOption.is(':disabled') ) {
$rowId = parseInt( jQuery(this).parents('tr').prev().find('.row-id pre').text() );
$primaryButton.attr('disabled', true);
$primaryButton[0].onclick = null;
if( $rowId != parseInt( $selectedOption.attr('data-id') ) ) {
$primaryButton.text('This field has already been added to the form');
}
} else {
$primaryButton.attr('disabled', false);
var tempBtnOnClick = $primaryButton.attr('onclick');
$primaryButton.text('Save Changes').removeAttr('onclick').attr('onclick', tempBtnOnClick);
}
});
}
/*
* Check to see if the selected field in the edit field select drop-down is disabled
* If it is we want to disable saving, because no changes have been made
*/
function wppb_check_update_field_options_disabled() {
jQuery('.update_container_wppb_rf_fields #field, .update_container_wppb_epf_fields #field').each( function() {
if( jQuery(this).find('option:selected').is(':disabled') ) {
jQuery(this).parents('.mb-list-entry-fields').find('.button-primary').attr('disabled', true);
jQuery(this).parents('.mb-list-entry-fields').find('.button-primary')[0].onclick = null;
}
});
}
/*
* Function that sends an ajax request to delete all items(fields) from a form
*
*/
function wppb_rf_epf_delete_all_fields(event, delete_all_button_id, nonce) {
event.preventDefault();
$deleteButton = jQuery('#' + delete_all_button_id);
var response = confirm( "Are you sure you want to delete all items ?" );
if( response == true ) {
$tableParent = $deleteButton.parents('table');
var meta = $tableParent.attr('id').replace('container_', '');
var post_id = parseInt( $tableParent.attr('post') );
$tableParent.parent().css({'opacity':'0.4', 'position':'relative'}).append('<div id="mb-ajax-loading"></div>');
jQuery.post( ajaxurl, { action: "wppb_rf_epf_delete_all_fields", meta: meta, id: post_id, _ajax_nonce: nonce }, function(response) {
/* refresh the list */
jQuery.post( wppbWckAjaxurl, { action: "wck_refresh_list"+meta, meta: meta, id: post_id}, function(response) {
jQuery('#container_'+meta).replaceWith(response);
$tableParent = jQuery('#container_'+meta);
$tableParent.find('tbody td').css('width', function(){ return jQuery(this).width() });
mb_sortable_elements();
$tableParent.parent().css('opacity','1');
jQuery('#mb-ajax-loading').remove();
});
});
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,237 +1,237 @@
/*
* Function to download/activate add-ons on button click
*/
jQuery('.wppb-add-on .button').on( 'click', function(e) {
if( jQuery(this).attr('disabled') ) {
return false;
}
// Activate add-on
if( jQuery(this).hasClass('wppb-add-on-activate') ) {
e.preventDefault();
wppb_add_on_activate( jQuery(this) );
}
// Deactivate add-on
if( jQuery(this).hasClass('wppb-add-on-deactivate') ) {
e.preventDefault();
wppb_add_on_deactivate( jQuery(this) );
}
});
/*
* Make deactivate button from Add-On is Active message button
*/
jQuery('.wppb-add-on').on( 'hover', function() {
$button = jQuery(this).find('.wppb-add-on-deactivate');
if( $button.length > 0 ) {
$button
.animate({
opacity: 1
}, 100);
}
});
/*
* Make Add-On is Active message button from deactivate button
*/
jQuery('.wppb-add-on').on( 'mouseleave', function() {
$button = jQuery(this).find('.wppb-add-on-deactivate');
if( $button.length > 0 ) {
$button
.animate({
opacity: 0
}, 100);
}
});
/*
* Function that activates the add-on
*/
function wppb_add_on_activate( $button ) {
$activate_button = $button;
var fade_in_out_speed = 300;
var plugin = $activate_button.attr('href');
var add_on_index = $activate_button.parents('.wppb-add-on').index('.wppb-add-on');
var nonce = $activate_button.data('nonce');
$activate_button
.attr('disabled', true);
$spinner = $activate_button.siblings('.spinner');
$spinner.animate({
opacity: 0.7
}, 100);
// Remove the current displayed message
wppb_add_on_remove_status_message( $activate_button, fade_in_out_speed);
jQuery.post( ajaxurl, { action: 'wppb_add_on_activate', wppb_add_on_to_activate: plugin, wppb_add_on_index: add_on_index, nonce: nonce }, function( response ) {
add_on_index = response;
$activate_button = jQuery('.wppb-add-on').eq( add_on_index ).find('.button');
$activate_button
.blur()
.removeClass('wppb-add-on-activate')
.addClass('wppb-add-on-deactivate')
.removeAttr('disabled')
.text( jQuery('#wppb-add-on-deactivate-button-text').text() );
$spinner = $activate_button.siblings('.spinner');
$spinner.animate({
opacity: 0
}, 0);
// Set status confirmation message
wppb_add_on_set_status_message( $activate_button, 'dashicons-yes', jQuery('#wppb-add-on-activated-message-text').text(), fade_in_out_speed, 0, true );
wppb_add_on_remove_status_message( $activate_button, fade_in_out_speed, 2000 );
// Set is active message
wppb_add_on_set_status_message( $activate_button, 'dashicons-yes', jQuery('#wppb-add-on-is-active-message-text').html(), fade_in_out_speed, 2000 + fade_in_out_speed );
});
}
/*
* Function that deactivates the add-on
*/
function wppb_add_on_deactivate( $button ) {
var fade_in_out_speed = 300;
var plugin = $button.attr('href');
var add_on_index = $button.parents('.wppb-add-on').index('.wppb-add-on');
var nonce = $button.data('nonce');
$button
.removeClass('wppb-add-on-deactivate')
.attr('disabled', true);
$spinner = $button.siblings('.spinner');
$spinner.animate({
opacity: 0.7
}, 100);
// Remove the current displayed message
wppb_add_on_remove_status_message( $button, fade_in_out_speed );
jQuery.post( ajaxurl, { action: 'wppb_add_on_deactivate', wppb_add_on_to_deactivate: plugin, wppb_add_on_index: add_on_index, nonce: nonce }, function( response ) {
add_on_index = response;
$button = jQuery('.wppb-add-on').eq( add_on_index ).find('.button');
$button
.blur()
.removeClass('wppb-add-on-is-active')
.addClass('wppb-add-on-activate')
.attr( 'disabled', false )
.text( jQuery('#wppb-add-on-activate-button-text').text() );
$spinner = $button.siblings('.spinner');
$spinner.animate({
opacity: 0
}, 0);
// Set status confirmation message
wppb_add_on_set_status_message( $button, 'dashicons-yes', jQuery('#wppb-add-on-deactivated-message-text').text(), fade_in_out_speed, 0, true );
wppb_add_on_remove_status_message( $button, fade_in_out_speed, 2000 );
// Set is active message
wppb_add_on_set_status_message( $button, 'dashicons-no-alt', jQuery('#wppb-add-on-is-not-active-message-text').html(), fade_in_out_speed, 2000 + fade_in_out_speed );
});
}
/*
* Function used to remove the status message of an add-on
*
* @param object $button - The jQuery object of the add-on box button that was pressed
* @param int fade_in_out_speed - The speed of the fade in and out animations
* @param int delay - Delay removing of the message
*
*/
function wppb_add_on_remove_status_message( $button, fade_in_out_speed, delay ) {
if( typeof( delay ) == 'undefined' ) {
delay = 0;
}
setTimeout( function() {
$button.siblings('.dashicons')
.animate({
opacity: 0
}, fade_in_out_speed );
$button.siblings('.wppb-add-on-message')
.animate({
opacity: 0
}, fade_in_out_speed );
}, delay);
}
/*
* Function used to remove the status message of an add-on
*
* @param object $button - The jQuery object of the add-on box button that was pressed
* @param string message_icon_class - The string name of the class we want the icon to have
* @param string message_text - The text we want the user to see
* @param int fade_in_out_speed - The speed of the fade in and out animations
* @param bool success - If true adds a class to style the message as a success one, if false adds a class to style the message as a failure
*
*/
function wppb_add_on_set_status_message( $button, message_icon_class, message_text, fade_in_out_speed, delay, success ) {
if( typeof( delay ) == 'undefined' ) {
delay = 0;
}
setTimeout(function() {
$button.siblings('.dashicons')
.css('opacity', 0)
.attr('class', 'dashicons')
.addClass( message_icon_class )
.animate({ opacity: 1}, fade_in_out_speed);
$button.siblings('.wppb-add-on-message')
.css('opacity', 0)
.attr( 'class', 'wppb-add-on-message' )
.html( message_text )
.animate({ opacity: 1}, fade_in_out_speed);
if( typeof( success ) != 'undefined' ) {
if( success == true ) {
$button.siblings('.dashicons')
.addClass('wppb-confirmation-success');
$button.siblings('.wppb-add-on-message')
.addClass('wppb-confirmation-success');
} else if( success == false ) {
$button.siblings('.dashicons')
.addClass('wppb-confirmation-error');
$button.siblings('.wppb-add-on-message')
.addClass('wppb-confirmation-error');
}
}
}, delay );
/*
* Function to download/activate add-ons on button click
*/
jQuery('.wppb-add-on .button').on( 'click', function(e) {
if( jQuery(this).attr('disabled') ) {
return false;
}
// Activate add-on
if( jQuery(this).hasClass('wppb-add-on-activate') ) {
e.preventDefault();
wppb_add_on_activate( jQuery(this) );
}
// Deactivate add-on
if( jQuery(this).hasClass('wppb-add-on-deactivate') ) {
e.preventDefault();
wppb_add_on_deactivate( jQuery(this) );
}
});
/*
* Make deactivate button from Add-On is Active message button
*/
jQuery('.wppb-add-on').on( 'hover', function() {
$button = jQuery(this).find('.wppb-add-on-deactivate');
if( $button.length > 0 ) {
$button
.animate({
opacity: 1
}, 100);
}
});
/*
* Make Add-On is Active message button from deactivate button
*/
jQuery('.wppb-add-on').on( 'mouseleave', function() {
$button = jQuery(this).find('.wppb-add-on-deactivate');
if( $button.length > 0 ) {
$button
.animate({
opacity: 0
}, 100);
}
});
/*
* Function that activates the add-on
*/
function wppb_add_on_activate( $button ) {
$activate_button = $button;
var fade_in_out_speed = 300;
var plugin = $activate_button.attr('href');
var add_on_index = $activate_button.parents('.wppb-add-on').index('.wppb-add-on');
var nonce = $activate_button.data('nonce');
$activate_button
.attr('disabled', true);
$spinner = $activate_button.siblings('.spinner');
$spinner.animate({
opacity: 0.7
}, 100);
// Remove the current displayed message
wppb_add_on_remove_status_message( $activate_button, fade_in_out_speed);
jQuery.post( ajaxurl, { action: 'wppb_add_on_activate', wppb_add_on_to_activate: plugin, wppb_add_on_index: add_on_index, nonce: nonce }, function( response ) {
add_on_index = response;
$activate_button = jQuery('.wppb-add-on').eq( add_on_index ).find('.button');
$activate_button
.blur()
.removeClass('wppb-add-on-activate')
.addClass('wppb-add-on-deactivate')
.removeAttr('disabled')
.text( jQuery('#wppb-add-on-deactivate-button-text').text() );
$spinner = $activate_button.siblings('.spinner');
$spinner.animate({
opacity: 0
}, 0);
// Set status confirmation message
wppb_add_on_set_status_message( $activate_button, 'dashicons-yes', jQuery('#wppb-add-on-activated-message-text').text(), fade_in_out_speed, 0, true );
wppb_add_on_remove_status_message( $activate_button, fade_in_out_speed, 2000 );
// Set is active message
wppb_add_on_set_status_message( $activate_button, 'dashicons-yes', jQuery('#wppb-add-on-is-active-message-text').html(), fade_in_out_speed, 2000 + fade_in_out_speed );
});
}
/*
* Function that deactivates the add-on
*/
function wppb_add_on_deactivate( $button ) {
var fade_in_out_speed = 300;
var plugin = $button.attr('href');
var add_on_index = $button.parents('.wppb-add-on').index('.wppb-add-on');
var nonce = $button.data('nonce');
$button
.removeClass('wppb-add-on-deactivate')
.attr('disabled', true);
$spinner = $button.siblings('.spinner');
$spinner.animate({
opacity: 0.7
}, 100);
// Remove the current displayed message
wppb_add_on_remove_status_message( $button, fade_in_out_speed );
jQuery.post( ajaxurl, { action: 'wppb_add_on_deactivate', wppb_add_on_to_deactivate: plugin, wppb_add_on_index: add_on_index, nonce: nonce }, function( response ) {
add_on_index = response;
$button = jQuery('.wppb-add-on').eq( add_on_index ).find('.button');
$button
.blur()
.removeClass('wppb-add-on-is-active')
.addClass('wppb-add-on-activate')
.attr( 'disabled', false )
.text( jQuery('#wppb-add-on-activate-button-text').text() );
$spinner = $button.siblings('.spinner');
$spinner.animate({
opacity: 0
}, 0);
// Set status confirmation message
wppb_add_on_set_status_message( $button, 'dashicons-yes', jQuery('#wppb-add-on-deactivated-message-text').text(), fade_in_out_speed, 0, true );
wppb_add_on_remove_status_message( $button, fade_in_out_speed, 2000 );
// Set is active message
wppb_add_on_set_status_message( $button, 'dashicons-no-alt', jQuery('#wppb-add-on-is-not-active-message-text').html(), fade_in_out_speed, 2000 + fade_in_out_speed );
});
}
/*
* Function used to remove the status message of an add-on
*
* @param object $button - The jQuery object of the add-on box button that was pressed
* @param int fade_in_out_speed - The speed of the fade in and out animations
* @param int delay - Delay removing of the message
*
*/
function wppb_add_on_remove_status_message( $button, fade_in_out_speed, delay ) {
if( typeof( delay ) == 'undefined' ) {
delay = 0;
}
setTimeout( function() {
$button.siblings('.dashicons')
.animate({
opacity: 0
}, fade_in_out_speed );
$button.siblings('.wppb-add-on-message')
.animate({
opacity: 0
}, fade_in_out_speed );
}, delay);
}
/*
* Function used to remove the status message of an add-on
*
* @param object $button - The jQuery object of the add-on box button that was pressed
* @param string message_icon_class - The string name of the class we want the icon to have
* @param string message_text - The text we want the user to see
* @param int fade_in_out_speed - The speed of the fade in and out animations
* @param bool success - If true adds a class to style the message as a success one, if false adds a class to style the message as a failure
*
*/
function wppb_add_on_set_status_message( $button, message_icon_class, message_text, fade_in_out_speed, delay, success ) {
if( typeof( delay ) == 'undefined' ) {
delay = 0;
}
setTimeout(function() {
$button.siblings('.dashicons')
.css('opacity', 0)
.attr('class', 'dashicons')
.addClass( message_icon_class )
.animate({ opacity: 1}, fade_in_out_speed);
$button.siblings('.wppb-add-on-message')
.css('opacity', 0)
.attr( 'class', 'wppb-add-on-message' )
.html( message_text )
.animate({ opacity: 1}, fade_in_out_speed);
if( typeof( success ) != 'undefined' ) {
if( success == true ) {
$button.siblings('.dashicons')
.addClass('wppb-confirmation-success');
$button.siblings('.wppb-add-on-message')
.addClass('wppb-confirmation-success');
} else if( success == false ) {
$button.siblings('.dashicons')
.addClass('wppb-confirmation-error');
$button.siblings('.wppb-add-on-message')
.addClass('wppb-confirmation-error');
}
}
}, delay );
}

View File

@ -1,133 +1,133 @@
/**
* Add a negative letter spacing to Profile Builder email customizer menus.
*/
jQuery( document ).ready(function(){
jQuery('li a[href$="admin-email-customizer"]').css("letter-spacing", "-0.7px");
jQuery('li a[href$="user-email-customizer"]').css("letter-spacing", "-0.7px");
});
/*
* Set the width of the shortcode input based on an element that
* has the width of its contents
*/
function setShortcodeInputWidth( $inputField ) {
var tempSpan = document.createElement('span');
tempSpan.className = "wppb-shortcode-temp";
tempSpan.innerHTML = $inputField.val();
document.body.appendChild(tempSpan);
var tempWidth = tempSpan.scrollWidth;
document.body.removeChild(tempSpan);
$inputField.outerWidth( tempWidth );
}
jQuery( document ).ready( function() {
jQuery('.wppb-shortcode.input').each( function() {
setShortcodeInputWidth( jQuery(this) );
});
jQuery('.wppb-shortcode.textarea').each( function() {
jQuery(this).outerHeight( jQuery(this)[0].scrollHeight + parseInt( jQuery(this).css('border-top-width') ) * 2 );
});
jQuery('.wppb-shortcode').click( function() {
this.select();
});
});
/* make sure that we don;t leave the page without having a title in the Post Title field, otherwise we loose data */
jQuery( function(){
if( jQuery( 'body').hasClass('post-new-php') ){
if( jQuery( 'body').hasClass('post-type-wppb-rf-cpt') || jQuery( 'body').hasClass('post-type-wppb-epf-cpt') || jQuery( 'body').hasClass('post-type-wppb-ul-cpt') ){
if( jQuery('#title').val() == '' ){
jQuery(window).bind('beforeunload',function() {
return "This page is asking you to confirm that you want to leave - data you have entered may not be saved";
});
}
/* remove beforeunload event when entering a title or pressing the puclish button */
jQuery( '#title').keypress(function() {
jQuery(window).unbind('beforeunload');
});
jQuery( '#publish').click( function() {
jQuery(window).unbind('beforeunload');
});
}
}
});
/* show hide fields based on selected options */
jQuery( function(){
jQuery( '#wppb-rf-settings-args').on('change', '#redirect', function(){
if( jQuery(this).val() == 'Yes' ){
jQuery( '.row-url, .row-display-messages', jQuery(this).parent().parent().parent()).show();
}
else{
jQuery( '.row-url, .row-display-messages', jQuery(this).parent().parent().parent()).hide();
}
});
jQuery( '#wppb-epf-settings-args').on('change', '#redirect', function(){
if( jQuery(this).val() == 'Yes' ){
jQuery( '.row-url, .row-display-messages', jQuery(this).parent().parent().parent()).show();
}
else{
jQuery( '.row-url, .row-display-messages', jQuery(this).parent().parent().parent()).hide();
}
});
jQuery( '#wppb-ul-settings-args').on('click', '#visible-only-to-logged-in-users_yes', function(){
jQuery( '.row-visible-to-following-roles', jQuery(this).parent().parent().parent().parent().parent().parent()).toggle();
});
jQuery( '#wppb-ul-faceted-args').on('change', '#facet-type', function(){
if( jQuery(this).val() == 'checkboxes' ){
jQuery( '.row-facet-behaviour, .row-facet-limit', jQuery(this).parent().parent().parent()).show();
}
else{
jQuery( '.row-facet-behaviour, .row-facet-limit', jQuery(this).parent().parent().parent()).hide();
jQuery( '.row-facet-behaviour #facet-behaviour', jQuery(this).parent().parent().parent()).val('narrow');
}
if( jQuery(this).val() == 'search' ){
jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="billing_country"] ').hide();
jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="shipping_country"] ').hide();
jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="billing_state"] ').hide();
jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="shipping_state"] ').hide();
}
else {
jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="billing_country"] ').show();
jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="shipping_country"] ').show();
jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="billing_state"] ').show();
jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="shipping_state"] ').show()
}
});
});
/*
* Dialog boxes throughout Profile Builder
*/
jQuery( function() {
if ( jQuery.fn.dialog ) {
jQuery('.wppb-modal-box').dialog({
autoOpen: false,
modal: true,
draggable: false,
minWidth: 450,
minHeight: 450
});
jQuery('.wppb-open-modal-box').click(function (e) {
e.preventDefault();
jQuery('#' + jQuery(this).attr('href')).dialog('open');
});
}
});
/**
* Add a negative letter spacing to Profile Builder email customizer menus.
*/
jQuery( document ).ready(function(){
jQuery('li a[href$="admin-email-customizer"]').css("letter-spacing", "-0.7px");
jQuery('li a[href$="user-email-customizer"]').css("letter-spacing", "-0.7px");
});
/*
* Set the width of the shortcode input based on an element that
* has the width of its contents
*/
function setShortcodeInputWidth( $inputField ) {
var tempSpan = document.createElement('span');
tempSpan.className = "wppb-shortcode-temp";
tempSpan.innerHTML = $inputField.val();
document.body.appendChild(tempSpan);
var tempWidth = tempSpan.scrollWidth;
document.body.removeChild(tempSpan);
$inputField.outerWidth( tempWidth );
}
jQuery( document ).ready( function() {
jQuery('.wppb-shortcode.input').each( function() {
setShortcodeInputWidth( jQuery(this) );
});
jQuery('.wppb-shortcode.textarea').each( function() {
jQuery(this).outerHeight( jQuery(this)[0].scrollHeight + parseInt( jQuery(this).css('border-top-width') ) * 2 );
});
jQuery('.wppb-shortcode').click( function() {
this.select();
});
});
/* make sure that we don;t leave the page without having a title in the Post Title field, otherwise we loose data */
jQuery( function(){
if( jQuery( 'body').hasClass('post-new-php') ){
if( jQuery( 'body').hasClass('post-type-wppb-rf-cpt') || jQuery( 'body').hasClass('post-type-wppb-epf-cpt') || jQuery( 'body').hasClass('post-type-wppb-ul-cpt') ){
if( jQuery('#title').val() == '' ){
jQuery(window).bind('beforeunload',function() {
return "This page is asking you to confirm that you want to leave - data you have entered may not be saved";
});
}
/* remove beforeunload event when entering a title or pressing the puclish button */
jQuery( '#title').keypress(function() {
jQuery(window).unbind('beforeunload');
});
jQuery( '#publish').click( function() {
jQuery(window).unbind('beforeunload');
});
}
}
});
/* show hide fields based on selected options */
jQuery( function(){
jQuery( '#wppb-rf-settings-args').on('change', '#redirect', function(){
if( jQuery(this).val() == 'Yes' ){
jQuery( '.row-url, .row-display-messages', jQuery(this).parent().parent().parent()).show();
}
else{
jQuery( '.row-url, .row-display-messages', jQuery(this).parent().parent().parent()).hide();
}
});
jQuery( '#wppb-epf-settings-args').on('change', '#redirect', function(){
if( jQuery(this).val() == 'Yes' ){
jQuery( '.row-url, .row-display-messages', jQuery(this).parent().parent().parent()).show();
}
else{
jQuery( '.row-url, .row-display-messages', jQuery(this).parent().parent().parent()).hide();
}
});
jQuery( '#wppb-ul-settings-args').on('click', '#visible-only-to-logged-in-users_yes', function(){
jQuery( '.row-visible-to-following-roles', jQuery(this).parent().parent().parent().parent().parent().parent()).toggle();
});
jQuery( '#wppb-ul-faceted-args').on('change', '#facet-type', function(){
if( jQuery(this).val() == 'checkboxes' ){
jQuery( '.row-facet-behaviour, .row-facet-limit', jQuery(this).parent().parent().parent()).show();
}
else{
jQuery( '.row-facet-behaviour, .row-facet-limit', jQuery(this).parent().parent().parent()).hide();
jQuery( '.row-facet-behaviour #facet-behaviour', jQuery(this).parent().parent().parent()).val('narrow');
}
if( jQuery(this).val() == 'search' ){
jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="billing_country"] ').hide();
jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="shipping_country"] ').hide();
jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="billing_state"] ').hide();
jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="shipping_state"] ').hide();
}
else {
jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="billing_country"] ').show();
jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="shipping_country"] ').show();
jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="billing_state"] ').show();
jQuery( '#wppb-ul-faceted-args .row-facet-meta #facet-meta option[value="shipping_state"] ').show()
}
});
});
/*
* Dialog boxes throughout Profile Builder
*/
jQuery( function() {
if ( jQuery.fn.dialog ) {
jQuery('.wppb-modal-box').dialog({
autoOpen: false,
modal: true,
draggable: false,
minWidth: 450,
minHeight: 450
});
jQuery('.wppb-open-modal-box').click(function (e) {
e.preventDefault();
jQuery('#' + jQuery(this).attr('href')).dialog('open');
});
}
});

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/ar",[],function(){return{errorLoading:function(){return"لا يمكن تحميل النتائج"},inputTooLong:function(e){var t=e.input.length-e.maximum,n="الرجاء حذف "+t+" عناصر";return n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="الرجاء إضافة "+t+" عناصر";return n},loadingMore:function(){return"جاري تحميل نتائج إضافية..."},maximumSelected:function(e){var t="تستطيع إختيار "+e.maximum+" بنود فقط";return t},noResults:function(){return"لم يتم العثور على أي نتائج"},searching:function(){return"جاري البحث…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/az",[],function(){return{inputTooLong:function(e){var t=e.input.length-e.maximum;return t+" simvol silin"},inputTooShort:function(e){var t=e.minimum-e.input.length;return t+" simvol daxil edin"},loadingMore:function(){return"Daha çox nəticə yüklənir…"},maximumSelected:function(e){return"Sadəcə "+e.maximum+" element seçə bilərsiniz"},noResults:function(){return"Nəticə tapılmadı"},searching:function(){return"Axtarılır…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/bg",[],function(){return{inputTooLong:function(e){var t=e.input.length-e.maximum,n="Моля въведете с "+t+" по-малко символ";return t>1&&(n+="a"),n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Моля въведете още "+t+" символ";return t>1&&(n+="a"),n},loadingMore:function(){return"Зареждат се още…"},maximumSelected:function(e){var t="Можете да направите до "+e.maximum+" ";return e.maximum>1?t+="избора":t+="избор",t},noResults:function(){return"Няма намерени съвпадения"},searching:function(){return"Търсене…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/ca",[],function(){return{errorLoading:function(){return"La càrrega ha fallat"},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Si us plau, elimina "+t+" car";return t==1?n+="àcter":n+="àcters",n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Si us plau, introdueix "+t+" car";return t==1?n+="àcter":n+="àcters",n},loadingMore:function(){return"Carregant més resultats…"},maximumSelected:function(e){var t="Només es pot seleccionar "+e.maximum+" element";return e.maximum!=1&&(t+="s"),t},noResults:function(){return"No s'han trobat resultats"},searching:function(){return"Cercant…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/cs",[],function(){function e(e,t){switch(e){case 2:return t?"dva":"dvě";case 3:return"tři";case 4:return"čtyři"}return""}return{errorLoading:function(){return"Výsledky nemohly být načteny."},inputTooLong:function(t){var n=t.input.length-t.maximum;return n==1?"Prosím zadejte o jeden znak méně":n<=4?"Prosím zadejte o "+e(n,!0)+" znaky méně":"Prosím zadejte o "+n+" znaků méně"},inputTooShort:function(t){var n=t.minimum-t.input.length;return n==1?"Prosím zadejte ještě jeden znak":n<=4?"Prosím zadejte ještě další "+e(n,!0)+" znaky":"Prosím zadejte ještě dalších "+n+" znaků"},loadingMore:function(){return"Načítají se další výsledky…"},maximumSelected:function(t){var n=t.maximum;return n==1?"Můžete zvolit jen jednu položku":n<=4?"Můžete zvolit maximálně "+e(n,!1)+" položky":"Můžete zvolit maximálně "+n+" položek"},noResults:function(){return"Nenalezeny žádné položky"},searching:function(){return"Vyhledávání…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/da",[],function(){return{errorLoading:function(){return"Resultaterne kunne ikke indlæses."},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Angiv venligst "+t+" tegn mindre";return n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Angiv venligst "+t+" tegn mere";return n},loadingMore:function(){return"Indlæser flere resultater…"},maximumSelected:function(e){var t="Du kan kun vælge "+e.maximum+" emne";return e.maximum!=1&&(t+="r"),t},noResults:function(){return"Ingen resultater fundet"},searching:function(){return"Søger…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/de",[],function(){return{inputTooLong:function(e){var t=e.input.length-e.maximum;return"Bitte "+t+" Zeichen weniger eingeben"},inputTooShort:function(e){var t=e.minimum-e.input.length;return"Bitte "+t+" Zeichen mehr eingeben"},loadingMore:function(){return"Lade mehr Ergebnisse…"},maximumSelected:function(e){var t="Sie können nur "+e.maximum+" Eintr";return e.maximum===1?t+="ag":t+="äge",t+=" auswählen",t},noResults:function(){return"Keine Übereinstimmungen gefunden"},searching:function(){return"Suche…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/el",[],function(){return{errorLoading:function(){return"Τα αποτελέσματα δεν μπόρεσαν να φορτώσουν."},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Παρακαλώ διαγράψτε "+t+" χαρακτήρ";return t==1&&(n+="α"),t!=1&&(n+="ες"),n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Παρακαλώ συμπληρώστε "+t+" ή περισσότερους χαρακτήρες";return n},loadingMore:function(){return"Φόρτωση περισσότερων αποτελεσμάτων…"},maximumSelected:function(e){var t="Μπορείτε να επιλέξετε μόνο "+e.maximum+" επιλογ";return e.maximum==1&&(t+="ή"),e.maximum!=1&&(t+="ές"),t},noResults:function(){return"Δεν βρέθηκαν αποτελέσματα"},searching:function(){return"Αναζήτηση…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/en",[],function(){return{errorLoading:function(){return"The results could not be loaded."},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Please delete "+t+" character";return t!=1&&(n+="s"),n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Please enter "+t+" or more characters";return n},loadingMore:function(){return"Loading more results…"},maximumSelected:function(e){var t="You can only select "+e.maximum+" item";return e.maximum!=1&&(t+="s"),t},noResults:function(){return"No results found"},searching:function(){return"Searching…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/es",[],function(){return{errorLoading:function(){return"La carga falló"},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Por favor, elimine "+t+" car";return t==1?n+="ácter":n+="acteres",n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Por favor, introduzca "+t+" car";return t==1?n+="ácter":n+="acteres",n},loadingMore:function(){return"Cargando más resultados…"},maximumSelected:function(e){var t="Sólo puede seleccionar "+e.maximum+" elemento";return e.maximum!=1&&(t+="s"),t},noResults:function(){return"No se encontraron resultados"},searching:function(){return"Buscando…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/et",[],function(){return{inputTooLong:function(e){var t=e.input.length-e.maximum,n="Sisesta "+t+" täht";return t!=1&&(n+="e"),n+=" vähem",n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Sisesta "+t+" täht";return t!=1&&(n+="e"),n+=" rohkem",n},loadingMore:function(){return"Laen tulemusi…"},maximumSelected:function(e){var t="Saad vaid "+e.maximum+" tulemus";return e.maximum==1?t+="e":t+="t",t+=" valida",t},noResults:function(){return"Tulemused puuduvad"},searching:function(){return"Otsin…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/eu",[],function(){return{inputTooLong:function(e){var t=e.input.length-e.maximum,n="Idatzi ";return t==1?n+="karaktere bat":n+=t+" karaktere",n+=" gutxiago",n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Idatzi ";return t==1?n+="karaktere bat":n+=t+" karaktere",n+=" gehiago",n},loadingMore:function(){return"Emaitza gehiago kargatzen…"},maximumSelected:function(e){return e.maximum===1?"Elementu bakarra hauta dezakezu":e.maximum+" elementu hauta ditzakezu soilik"},noResults:function(){return"Ez da bat datorrenik aurkitu"},searching:function(){return"Bilatzen…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/fa",[],function(){return{errorLoading:function(){return"امکان بارگذاری نتایج وجود ندارد."},inputTooLong:function(e){var t=e.input.length-e.maximum,n="لطفاً "+t+" کاراکتر را حذف نمایید";return n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="لطفاً تعداد "+t+" کاراکتر یا بیشتر وارد نمایید";return n},loadingMore:function(){return"در حال بارگذاری نتایج بیشتر..."},maximumSelected:function(e){var t="شما تنها می‌توانید "+e.maximum+" آیتم را انتخاب نمایید";return t},noResults:function(){return"هیچ نتیجه‌ای یافت نشد"},searching:function(){return"در حال جستجو..."}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/fi",[],function(){return{inputTooLong:function(e){var t=e.input.length-e.maximum;return"Ole hyvä ja anna "+t+" merkkiä vähemmän"},inputTooShort:function(e){var t=e.minimum-e.input.length;return"Ole hyvä ja anna "+t+" merkkiä lisää"},loadingMore:function(){return"Ladataan lisää tuloksia…"},maximumSelected:function(e){return"Voit valita ainoastaan "+e.maximum+" kpl"},noResults:function(){return"Ei tuloksia"},searching:function(){}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/fr",[],function(){return{errorLoading:function(){return"Les résultats ne peuvent pas être chargés."},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Supprimez "+t+" caractère";return t!==1&&(n+="s"),n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Saisissez "+t+" caractère";return t!==1&&(n+="s"),n},loadingMore:function(){return"Chargement de résultats supplémentaires…"},maximumSelected:function(e){var t="Vous pouvez seulement sélectionner "+e.maximum+" élément";return e.maximum!==1&&(t+="s"),t},noResults:function(){return"Aucun résultat trouvé"},searching:function(){return"Recherche en cours…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/gl",[],function(){return{inputTooLong:function(e){var t=e.input.length-e.maximum,n="Elimine ";return t===1?n+="un carácter":n+=t+" caracteres",n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Engada ";return t===1?n+="un carácter":n+=t+" caracteres",n},loadingMore:function(){return"Cargando máis resultados…"},maximumSelected:function(e){var t="Só pode ";return e.maximum===1?t+="un elemento":t+=e.maximum+" elementos",t},noResults:function(){return"Non se atoparon resultados"},searching:function(){return"Buscando…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/he",[],function(){return{errorLoading:function(){return"שגיאה בטעינת התוצאות"},inputTooLong:function(e){var t=e.input.length-e.maximum,n="נא למחוק ";return t===1?n+="תו אחד":n+=t+" תווים",n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="נא להכניס ";return t===1?n+="תו אחד":n+=t+" תווים",n+=" או יותר",n},loadingMore:function(){return"טוען תוצאות נוספות…"},maximumSelected:function(e){var t="באפשרותך לבחור עד ";return e.maximum===1?t+="פריט אחד":t+=e.maximum+" פריטים",t},noResults:function(){return"לא נמצאו תוצאות"},searching:function(){return"מחפש…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/hi",[],function(){return{errorLoading:function(){return"परिणामों को लोड नहीं किया जा सका।"},inputTooLong:function(e){var t=e.input.length-e.maximum,n=t+" अक्षर को हटा दें";return t>1&&(n=t+" अक्षरों को हटा दें "),n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="कृपया "+t+" या अधिक अक्षर दर्ज करें";return n},loadingMore:function(){return"अधिक परिणाम लोड हो रहे है..."},maximumSelected:function(e){var t="आप केवल "+e.maximum+" आइटम का चयन कर सकते हैं";return t},noResults:function(){return"कोई परिणाम नहीं मिला"},searching:function(){return"खोज रहा है..."}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/hr",[],function(){function e(e){var t=" "+e+" znak";return e%10<5&&e%10>0&&(e%100<5||e%100>19)?e%10>1&&(t+="a"):t+="ova",t}return{errorLoading:function(){return"Preuzimanje nije uspjelo."},inputTooLong:function(t){var n=t.input.length-t.maximum;return"Unesite "+e(n)},inputTooShort:function(t){var n=t.minimum-t.input.length;return"Unesite još "+e(n)},loadingMore:function(){return"Učitavanje rezultata…"},maximumSelected:function(e){return"Maksimalan broj odabranih stavki je "+e.maximum},noResults:function(){return"Nema rezultata"},searching:function(){return"Pretraga…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/hu",[],function(){return{inputTooLong:function(e){var t=e.input.length-e.maximum;return"Túl hosszú. "+t+" karakterrel több, mint kellene."},inputTooShort:function(e){var t=e.minimum-e.input.length;return"Túl rövid. Még "+t+" karakter hiányzik."},loadingMore:function(){return"Töltés…"},maximumSelected:function(e){return"Csak "+e.maximum+" elemet lehet kiválasztani."},noResults:function(){return"Nincs találat."},searching:function(){return"Keresés…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/id",[],function(){return{errorLoading:function(){return"Data tidak boleh diambil."},inputTooLong:function(e){var t=e.input.length-e.maximum;return"Hapuskan "+t+" huruf"},inputTooShort:function(e){var t=e.minimum-e.input.length;return"Masukkan "+t+" huruf lagi"},loadingMore:function(){return"Mengambil data…"},maximumSelected:function(e){return"Anda hanya dapat memilih "+e.maximum+" pilihan"},noResults:function(){return"Tidak ada data yang sesuai"},searching:function(){return"Mencari…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/is",[],function(){return{inputTooLong:function(e){var t=e.input.length-e.maximum,n="Vinsamlegast styttið texta um "+t+" staf";return t<=1?n:n+"i"},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Vinsamlegast skrifið "+t+" staf";return t>1&&(n+="i"),n+=" í viðbót",n},loadingMore:function(){return"Sæki fleiri niðurstöður…"},maximumSelected:function(e){return"Þú getur aðeins valið "+e.maximum+" atriði"},noResults:function(){return"Ekkert fannst"},searching:function(){return"Leita…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/it",[],function(){return{errorLoading:function(){return"I risultati non possono essere caricati."},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Per favore cancella "+t+" caratter";return t!==1?n+="i":n+="e",n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Per favore inserisci "+t+" o più caratteri";return n},loadingMore:function(){return"Caricando più risultati…"},maximumSelected:function(e){var t="Puoi selezionare solo "+e.maximum+" element";return e.maximum!==1?t+="i":t+="o",t},noResults:function(){return"Nessun risultato trovato"},searching:function(){return"Sto cercando…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/ja",[],function(){return{errorLoading:function(){return"結果が読み込まれませんでした"},inputTooLong:function(e){var t=e.input.length-e.maximum,n=t+" 文字を削除してください";return n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="少なくとも "+t+" 文字を入力してください";return n},loadingMore:function(){return"読み込み中…"},maximumSelected:function(e){var t=e.maximum+" 件しか選択できません";return t},noResults:function(){return"対象が見つかりません"},searching:function(){return"検索しています…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/km",[],function(){return{errorLoading:function(){return"មិនអាចទាញយកទិន្នន័យ"},inputTooLong:function(e){var t=e.input.length-e.maximum,n="សូមលុបចេញ "+t+" អក្សរ";return n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="សូមបញ្ចូល"+t+" អក្សរ រឺ ច្រើនជាងនេះ";return n},loadingMore:function(){return"កំពុងទាញយកទិន្នន័យបន្ថែម..."},maximumSelected:function(e){var t="អ្នកអាចជ្រើសរើសបានតែ "+e.maximum+" ជម្រើសប៉ុណ្ណោះ";return t},noResults:function(){return"មិនមានលទ្ធផល"},searching:function(){return"កំពុងស្វែងរក..."}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/ko",[],function(){return{errorLoading:function(){return"결과를 불러올 수 없습니다."},inputTooLong:function(e){var t=e.input.length-e.maximum,n="너무 깁니다. "+t+" 글자 지워주세요.";return n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="너무 짧습니다. "+t+" 글자 더 입력해주세요.";return n},loadingMore:function(){return"불러오는 중…"},maximumSelected:function(e){var t="최대 "+e.maximum+"개까지만 선택 가능합니다.";return t},noResults:function(){return"결과가 없습니다."},searching:function(){return"검색 중…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/lt",[],function(){function e(e,t,n,r){return e%10===1&&(e%100<11||e%100>19)?t:e%10>=2&&e%10<=9&&(e%100<11||e%100>19)?n:r}return{inputTooLong:function(t){var n=t.input.length-t.maximum,r="Pašalinkite "+n+" simbol";return r+=e(n,"į","ius","ių"),r},inputTooShort:function(t){var n=t.minimum-t.input.length,r="Įrašykite dar "+n+" simbol";return r+=e(n,"į","ius","ių"),r},loadingMore:function(){return"Kraunama daugiau rezultatų…"},maximumSelected:function(t){var n="Jūs galite pasirinkti tik "+t.maximum+" element";return n+=e(t.maximum,"ą","us","ų"),n},noResults:function(){return"Atitikmenų nerasta"},searching:function(){return"Ieškoma…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/lv",[],function(){function e(e,t,n,r){return e===11?t:e%10===1?n:r}return{inputTooLong:function(t){var n=t.input.length-t.maximum,r="Lūdzu ievadiet par "+n;return r+=" simbol"+e(n,"iem","u","iem"),r+" mazāk"},inputTooShort:function(t){var n=t.minimum-t.input.length,r="Lūdzu ievadiet vēl "+n;return r+=" simbol"+e(n,"us","u","us"),r},loadingMore:function(){return"Datu ielāde…"},maximumSelected:function(t){var n="Jūs varat izvēlēties ne vairāk kā "+t.maximum;return n+=" element"+e(t.maximum,"us","u","us"),n},noResults:function(){return"Sakritību nav"},searching:function(){return"Meklēšana…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/mk",[],function(){return{inputTooLong:function(e){var t=e.input.length-e.maximum,n="Ве молиме внесете "+e.maximum+" помалку карактер";return e.maximum!==1&&(n+="и"),n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Ве молиме внесете уште "+e.maximum+" карактер";return e.maximum!==1&&(n+="и"),n},loadingMore:function(){return"Вчитување резултати…"},maximumSelected:function(e){var t="Можете да изберете само "+e.maximum+" ставк";return e.maximum===1?t+="а":t+="и",t},noResults:function(){return"Нема пронајдено совпаѓања"},searching:function(){return"Пребарување…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/ms",[],function(){return{errorLoading:function(){return"Keputusan tidak berjaya dimuatkan."},inputTooLong:function(e){var t=e.input.length-e.maximum;return"Sila hapuskan "+t+" aksara"},inputTooShort:function(e){var t=e.minimum-e.input.length;return"Sila masukkan "+t+" atau lebih aksara"},loadingMore:function(){return"Sedang memuatkan keputusan…"},maximumSelected:function(e){return"Anda hanya boleh memilih "+e.maximum+" pilihan"},noResults:function(){return"Tiada padanan yang ditemui"},searching:function(){return"Mencari…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/nb",[],function(){return{errorLoading:function(){return"Kunne ikke hente resultater."},inputTooLong:function(e){var t=e.input.length-e.maximum;return"Vennligst fjern "+t+" tegn"},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Vennligst skriv inn ";return t>1?n+=" flere tegn":n+=" tegn til",n},loadingMore:function(){return"Laster flere resultater…"},maximumSelected:function(e){return"Du kan velge maks "+e.maximum+" elementer"},noResults:function(){return"Ingen treff"},searching:function(){return"Søker…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/nl",[],function(){return{errorLoading:function(){return"De resultaten konden niet worden geladen."},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Gelieve "+t+" karakters te verwijderen";return n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Gelieve "+t+" of meer karakters in te voeren";return n},loadingMore:function(){return"Meer resultaten laden…"},maximumSelected:function(e){var t=e.maximum==1?"kan":"kunnen",n="Er "+t+" maar "+e.maximum+" item";return e.maximum!=1&&(n+="s"),n+=" worden geselecteerd",n},noResults:function(){return"Geen resultaten gevonden…"},searching:function(){return"Zoeken…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/pl",[],function(){var e=["znak","znaki","znaków"],t=["element","elementy","elementów"],n=function(t,n){if(t===1)return n[0];if(t>1&&t<=4)return n[1];if(t>=5)return n[2]};return{errorLoading:function(){return"Nie można załadować wyników."},inputTooLong:function(t){var r=t.input.length-t.maximum;return"Usuń "+r+" "+n(r,e)},inputTooShort:function(t){var r=t.minimum-t.input.length;return"Podaj przynajmniej "+r+" "+n(r,e)},loadingMore:function(){return"Trwa ładowanie…"},maximumSelected:function(e){return"Możesz zaznaczyć tylko "+e.maximum+" "+n(e.maximum,t)},noResults:function(){return"Brak wyników"},searching:function(){return"Trwa wyszukiwanie…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/pt-BR",[],function(){return{errorLoading:function(){return"Os resultados não puderam ser carregados."},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Apague "+t+" caracter";return t!=1&&(n+="es"),n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Digite "+t+" ou mais caracteres";return n},loadingMore:function(){return"Carregando mais resultados…"},maximumSelected:function(e){var t="Você só pode selecionar "+e.maximum+" ite";return e.maximum==1?t+="m":t+="ns",t},noResults:function(){return"Nenhum resultado encontrado"},searching:function(){return"Buscando…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/pt",[],function(){return{errorLoading:function(){return"Os resultados não puderam ser carregados."},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Por favor apague "+t+" ";return n+=t!=1?"caracteres":"carácter",n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Introduza "+t+" ou mais caracteres";return n},loadingMore:function(){return"A carregar mais resultados…"},maximumSelected:function(e){var t="Apenas pode seleccionar "+e.maximum+" ";return t+=e.maximum!=1?"itens":"item",t},noResults:function(){return"Sem resultados"},searching:function(){return"A procurar…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/ro",[],function(){return{errorLoading:function(){return"Rezultatele nu au putut fi incărcate."},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Vă rugăm să ștergeți"+t+" caracter";return t!==1&&(n+="e"),n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Vă rugăm să introduceți "+t+"sau mai multe caractere";return n},loadingMore:function(){return"Se încarcă mai multe rezultate…"},maximumSelected:function(e){var t="Aveți voie să selectați cel mult "+e.maximum;return t+=" element",e.maximum!==1&&(t+="e"),t},noResults:function(){return"Nu au fost găsite rezultate"},searching:function(){return"Căutare…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/ru",[],function(){function e(e,t,n,r){return e%10<5&&e%10>0&&e%100<5||e%100>20?e%10>1?n:t:r}return{errorLoading:function(){return"Невозможно загрузить результаты"},inputTooLong:function(t){var n=t.input.length-t.maximum,r="Пожалуйста, введите на "+n+" символ";return r+=e(n,"","a","ов"),r+=" меньше",r},inputTooShort:function(t){var n=t.minimum-t.input.length,r="Пожалуйста, введите еще хотя бы "+n+" символ";return r+=e(n,"","a","ов"),r},loadingMore:function(){return"Загрузка данных…"},maximumSelected:function(t){var n="Вы можете выбрать не более "+t.maximum+" элемент";return n+=e(t.maximum,"","a","ов"),n},noResults:function(){return"Совпадений не найдено"},searching:function(){return"Поиск…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/sk",[],function(){var e={2:function(e){return e?"dva":"dve"},3:function(){return"tri"},4:function(){return"štyri"}};return{inputTooLong:function(t){var n=t.input.length-t.maximum;return n==1?"Prosím, zadajte o jeden znak menej":n>=2&&n<=4?"Prosím, zadajte o "+e[n](!0)+" znaky menej":"Prosím, zadajte o "+n+" znakov menej"},inputTooShort:function(t){var n=t.minimum-t.input.length;return n==1?"Prosím, zadajte ešte jeden znak":n<=4?"Prosím, zadajte ešte ďalšie "+e[n](!0)+" znaky":"Prosím, zadajte ešte ďalších "+n+" znakov"},loadingMore:function(){return"Loading more results…"},maximumSelected:function(t){return t.maximum==1?"Môžete zvoliť len jednu položku":t.maximum>=2&&t.maximum<=4?"Môžete zvoliť najviac "+e[t.maximum](!1)+" položky":"Môžete zvoliť najviac "+t.maximum+" položiek"},noResults:function(){return"Nenašli sa žiadne položky"},searching:function(){return"Vyhľadávanie…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/sr-Cyrl",[],function(){function e(e,t,n,r){return e%10==1&&e%100!=11?t:e%10>=2&&e%10<=4&&(e%100<12||e%100>14)?n:r}return{errorLoading:function(){return"Преузимање није успело."},inputTooLong:function(t){var n=t.input.length-t.maximum,r="Обришите "+n+" симбол";return r+=e(n,"","а","а"),r},inputTooShort:function(t){var n=t.minimum-t.input.length,r="Укуцајте бар још "+n+" симбол";return r+=e(n,"","а","а"),r},loadingMore:function(){return"Преузимање још резултата…"},maximumSelected:function(t){var n="Можете изабрати само "+t.maximum+" ставк";return n+=e(t.maximum,"у","е","и"),n},noResults:function(){return"Ништа није пронађено"},searching:function(){return"Претрага…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/sr",[],function(){function e(e,t,n,r){return e%10==1&&e%100!=11?t:e%10>=2&&e%10<=4&&(e%100<12||e%100>14)?n:r}return{errorLoading:function(){return"Preuzimanje nije uspelo."},inputTooLong:function(t){var n=t.input.length-t.maximum,r="Obrišite "+n+" simbol";return r+=e(n,"","a","a"),r},inputTooShort:function(t){var n=t.minimum-t.input.length,r="Ukucajte bar još "+n+" simbol";return r+=e(n,"","a","a"),r},loadingMore:function(){return"Preuzimanje još rezultata…"},maximumSelected:function(t){var n="Možete izabrati samo "+t.maximum+" stavk";return n+=e(t.maximum,"u","e","i"),n},noResults:function(){return"Ništa nije pronađeno"},searching:function(){return"Pretraga…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/sv",[],function(){return{errorLoading:function(){return"Resultat kunde inte laddas."},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Vänligen sudda ut "+t+" tecken";return n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Vänligen skriv in "+t+" eller fler tecken";return n},loadingMore:function(){return"Laddar fler resultat…"},maximumSelected:function(e){var t="Du kan max välja "+e.maximum+" element";return t},noResults:function(){return"Inga träffar"},searching:function(){return"Söker…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/th",[],function(){return{inputTooLong:function(e){var t=e.input.length-e.maximum,n="โปรดลบออก "+t+" ตัวอักษร";return n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="โปรดพิมพ์เพิ่มอีก "+t+" ตัวอักษร";return n},loadingMore:function(){return"กำลังค้นข้อมูลเพิ่ม…"},maximumSelected:function(e){var t="คุณสามารถเลือกได้ไม่เกิน "+e.maximum+" รายการ";return t},noResults:function(){return"ไม่พบข้อมูล"},searching:function(){return"กำลังค้นข้อมูล…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/tr",[],function(){return{inputTooLong:function(e){var t=e.input.length-e.maximum,n=t+" karakter daha girmelisiniz";return n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="En az "+t+" karakter daha girmelisiniz";return n},loadingMore:function(){return"Daha fazla…"},maximumSelected:function(e){var t="Sadece "+e.maximum+" seçim yapabilirsiniz";return t},noResults:function(){return"Sonuç bulunamadı"},searching:function(){return"Aranıyor…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/uk",[],function(){function e(e,t,n,r){return e%100>10&&e%100<15?r:e%10===1?t:e%10>1&&e%10<5?n:r}return{errorLoading:function(){return"Неможливо завантажити результати"},inputTooLong:function(t){var n=t.input.length-t.maximum;return"Будь ласка, видаліть "+n+" "+e(t.maximum,"літеру","літери","літер")},inputTooShort:function(e){var t=e.minimum-e.input.length;return"Будь ласка, введіть "+t+" або більше літер"},loadingMore:function(){return"Завантаження інших результатів…"},maximumSelected:function(t){return"Ви можете вибрати лише "+t.maximum+" "+e(t.maximum,"пункт","пункти","пунктів")},noResults:function(){return"Нічого не знайдено"},searching:function(){return"Пошук…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/vi",[],function(){return{inputTooLong:function(e){var t=e.input.length-e.maximum,n="Vui lòng nhập ít hơn "+t+" ký tự";return t!=1&&(n+="s"),n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Vui lòng nhập nhiều hơn "+t+' ký tự"';return n},loadingMore:function(){return"Đang lấy thêm kết quả…"},maximumSelected:function(e){var t="Chỉ có thể chọn được "+e.maximum+" lựa chọn";return t},noResults:function(){return"Không tìm thấy kết quả"},searching:function(){return"Đang tìm…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/zh-CN",[],function(){return{errorLoading:function(){return"无法载入结果。"},inputTooLong:function(e){var t=e.input.length-e.maximum,n="请删除"+t+"个字符";return n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="请再输入至少"+t+"个字符";return n},loadingMore:function(){return"载入更多结果…"},maximumSelected:function(e){var t="最多只能选择"+e.maximum+"个项目";return t},noResults:function(){return"未找到结果"},searching:function(){return"搜索中…"}}}),{define:e.define,require:e.require}})();

View File

@ -1,3 +1,3 @@
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/zh-TW",[],function(){return{inputTooLong:function(e){var t=e.input.length-e.maximum,n="請刪掉"+t+"個字元";return n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="請再輸入"+t+"個字元";return n},loadingMore:function(){return"載入中…"},maximumSelected:function(e){var t="你只能選擇最多"+e.maximum+"項";return t},noResults:function(){return"沒有找到相符的項目"},searching:function(){return"搜尋中…"}}}),{define:e.define,require:e.require}})();

File diff suppressed because one or more lines are too long

View File

@ -1,75 +1,75 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Mustache class autoloader.
*/
class Mustache_Autoloader
{
private $baseDir;
/**
* Autoloader constructor.
*
* @param string $baseDir Mustache library base directory (default: dirname(__FILE__).'/..')
*/
public function __construct($baseDir = null)
{
if ($baseDir === null) {
$baseDir = dirname(__FILE__).'/..';
}
// realpath doesn't always work, for example, with stream URIs
$realDir = realpath($baseDir);
if (is_dir($realDir)) {
$this->baseDir = $realDir;
} else {
$this->baseDir = $baseDir;
}
}
/**
* Register a new instance as an SPL autoloader.
*
* @param string $baseDir Mustache library base directory (default: dirname(__FILE__).'/..')
*
* @return Mustache_Autoloader Registered Autoloader instance
*/
public static function register($baseDir = null)
{
$loader = new self($baseDir);
spl_autoload_register(array($loader, 'autoload'));
return $loader;
}
/**
* Autoload Mustache classes.
*
* @param string $class
*/
public function autoload($class)
{
if ($class[0] === '\\') {
$class = substr($class, 1);
}
if (strpos($class, 'Mustache') !== 0) {
return;
}
$file = sprintf('%s/%s.php', $this->baseDir, str_replace('_', '/', $class));
if (is_file($file)) {
require $file;
}
}
}
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Mustache class autoloader.
*/
class Mustache_Autoloader
{
private $baseDir;
/**
* Autoloader constructor.
*
* @param string $baseDir Mustache library base directory (default: dirname(__FILE__).'/..')
*/
public function __construct($baseDir = null)
{
if ($baseDir === null) {
$baseDir = dirname(__FILE__).'/..';
}
// realpath doesn't always work, for example, with stream URIs
$realDir = realpath($baseDir);
if (is_dir($realDir)) {
$this->baseDir = $realDir;
} else {
$this->baseDir = $baseDir;
}
}
/**
* Register a new instance as an SPL autoloader.
*
* @param string $baseDir Mustache library base directory (default: dirname(__FILE__).'/..')
*
* @return Mustache_Autoloader Registered Autoloader instance
*/
public static function register($baseDir = null)
{
$loader = new self($baseDir);
spl_autoload_register(array($loader, 'autoload'));
return $loader;
}
/**
* Autoload Mustache classes.
*
* @param string $class
*/
public function autoload($class)
{
if ($class[0] === '\\') {
$class = substr($class, 1);
}
if (strpos($class, 'Mustache') !== 0) {
return;
}
$file = sprintf('%s/%s.php', $this->baseDir, str_replace('_', '/', $class));
if (is_file($file)) {
require $file;
}
}
}

View File

@ -1,476 +1,476 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Mustache Compiler class.
*
* This class is responsible for turning a Mustache token parse tree into normal PHP source code.
*/
class Mustache_Compiler
{
private $sections;
private $source;
private $indentNextLine;
private $customEscape;
private $entityFlags;
private $charset;
private $strictCallables;
private $pragmas;
/**
* Compile a Mustache token parse tree into PHP source code.
*
* @param string $source Mustache Template source code
* @param string $tree Parse tree of Mustache tokens
* @param string $name Mustache Template class name
* @param bool $customEscape (default: false)
* @param int $entityFlags (default: ENT_COMPAT)
* @param string $charset (default: 'UTF-8')
* @param bool $strictCallables (default: false)
*
* @return string Generated PHP source code
*/
public function compile($source, array $tree, $name, $customEscape = false, $charset = 'UTF-8', $strictCallables = false, $entityFlags = ENT_COMPAT)
{
$this->pragmas = array();
$this->sections = array();
$this->source = $source;
$this->indentNextLine = true;
$this->customEscape = $customEscape;
$this->entityFlags = $entityFlags;
$this->charset = $charset;
$this->strictCallables = $strictCallables;
return $this->writeCode($tree, $name);
}
/**
* Helper function for walking the Mustache token parse tree.
*
* @throws Mustache_Exception_SyntaxException upon encountering unknown token types.
*
* @param array $tree Parse tree of Mustache tokens
* @param int $level (default: 0)
*
* @return string Generated PHP source code
*/
private function walk(array $tree, $level = 0)
{
$code = '';
$level++;
foreach ($tree as $node) {
switch ($node[Mustache_Tokenizer::TYPE]) {
case Mustache_Tokenizer::T_PRAGMA:
$this->pragmas[$node[Mustache_Tokenizer::NAME]] = true;
break;
case Mustache_Tokenizer::T_SECTION:
$code .= $this->section(
$node[Mustache_Tokenizer::NODES],
$node[Mustache_Tokenizer::NAME],
$node[Mustache_Tokenizer::INDEX],
$node[Mustache_Tokenizer::END],
$node[Mustache_Tokenizer::OTAG],
$node[Mustache_Tokenizer::CTAG],
$level
);
break;
case Mustache_Tokenizer::T_INVERTED:
$code .= $this->invertedSection(
$node[Mustache_Tokenizer::NODES],
$node[Mustache_Tokenizer::NAME],
$level
);
break;
case Mustache_Tokenizer::T_PARTIAL:
case Mustache_Tokenizer::T_PARTIAL_2:
$code .= $this->partial(
$node[Mustache_Tokenizer::NAME],
isset($node[Mustache_Tokenizer::INDENT]) ? $node[Mustache_Tokenizer::INDENT] : '',
$level
);
break;
case Mustache_Tokenizer::T_UNESCAPED:
case Mustache_Tokenizer::T_UNESCAPED_2:
$code .= $this->variable($node[Mustache_Tokenizer::NAME], false, $level);
break;
case Mustache_Tokenizer::T_COMMENT:
break;
case Mustache_Tokenizer::T_ESCAPED:
$code .= $this->variable($node[Mustache_Tokenizer::NAME], true, $level);
break;
case Mustache_Tokenizer::T_TEXT:
$code .= $this->text($node[Mustache_Tokenizer::VALUE], $level);
break;
default:
throw new Mustache_Exception_SyntaxException(sprintf('Unknown token type: %s', $node[Mustache_Tokenizer::TYPE]), $node);
}
}
return $code;
}
const KLASS = '<?php
class %s extends Mustache_Template
{
private $lambdaHelper;%s
public function renderInternal(Mustache_Context $context, $indent = \'\')
{
$this->lambdaHelper = new Mustache_LambdaHelper($this->mustache, $context);
$buffer = \'\';
%s
return $buffer;
}
%s
}';
const KLASS_NO_LAMBDAS = '<?php
class %s extends Mustache_Template
{%s
public function renderInternal(Mustache_Context $context, $indent = \'\')
{
$buffer = \'\';
%s
return $buffer;
}
}';
const STRICT_CALLABLE = 'protected $strictCallables = true;';
/**
* Generate Mustache Template class PHP source.
*
* @param array $tree Parse tree of Mustache tokens
* @param string $name Mustache Template class name
*
* @return string Generated PHP source code
*/
private function writeCode($tree, $name)
{
$code = $this->walk($tree);
$sections = implode("\n", $this->sections);
$klass = empty($this->sections) ? self::KLASS_NO_LAMBDAS : self::KLASS;
$callable = $this->strictCallables ? $this->prepare(self::STRICT_CALLABLE) : '';
return sprintf($this->prepare($klass, 0, false, true), $name, $callable, $code, $sections);
}
const SECTION_CALL = '
// %s section
$buffer .= $this->section%s($context, $indent, $context->%s(%s));
';
const SECTION = '
private function section%s(Mustache_Context $context, $indent, $value)
{
$buffer = \'\';
if (%s) {
$source = %s;
$buffer .= $this->mustache
->loadLambda((string) call_user_func($value, $source, $this->lambdaHelper)%s)
->renderInternal($context);
} elseif (!empty($value)) {
$values = $this->isIterable($value) ? $value : array($value);
foreach ($values as $value) {
$context->push($value);%s
$context->pop();
}
}
return $buffer;
}';
/**
* Generate Mustache Template section PHP source.
*
* @param array $nodes Array of child tokens
* @param string $id Section name
* @param int $start Section start offset
* @param int $end Section end offset
* @param string $otag Current Mustache opening tag
* @param string $ctag Current Mustache closing tag
* @param int $level
*
* @return string Generated section PHP source code
*/
private function section($nodes, $id, $start, $end, $otag, $ctag, $level)
{
$method = $this->getFindMethod($id);
$id = var_export($id, true);
$source = var_export(substr($this->source, $start, $end - $start), true);
$callable = $this->getCallable();
if ($otag !== '{{' || $ctag !== '}}') {
$delims = ', '.var_export(sprintf('{{= %s %s =}}', $otag, $ctag), true);
} else {
$delims = '';
}
$key = ucfirst(md5($delims."\n".$source));
if (!isset($this->sections[$key])) {
$this->sections[$key] = sprintf($this->prepare(self::SECTION), $key, $callable, $source, $delims, $this->walk($nodes, 2));
}
return sprintf($this->prepare(self::SECTION_CALL, $level), $id, $key, $method, $id);
}
const INVERTED_SECTION = '
// %s inverted section
$value = $context->%s(%s);
if (empty($value)) {
%s
}';
/**
* Generate Mustache Template inverted section PHP source.
*
* @param array $nodes Array of child tokens
* @param string $id Section name
* @param int $level
*
* @return string Generated inverted section PHP source code
*/
private function invertedSection($nodes, $id, $level)
{
$method = $this->getFindMethod($id);
$id = var_export($id, true);
return sprintf($this->prepare(self::INVERTED_SECTION, $level), $id, $method, $id, $this->walk($nodes, $level));
}
const PARTIAL = '
if ($partial = $this->mustache->loadPartial(%s)) {
$buffer .= $partial->renderInternal($context, %s);
}
';
/**
* Generate Mustache Template partial call PHP source.
*
* @param string $id Partial name
* @param string $indent Whitespace indent to apply to partial
* @param int $level
*
* @return string Generated partial call PHP source code
*/
private function partial($id, $indent, $level)
{
return sprintf(
$this->prepare(self::PARTIAL, $level),
var_export($id, true),
var_export($indent, true)
);
}
const VARIABLE = '
$value = $this->resolveValue($context->%s(%s), $context, $indent);%s
$buffer .= %s%s;
';
/**
* Generate Mustache Template variable interpolation PHP source.
*
* @param string $id Variable name
* @param boolean $escape Escape the variable value for output?
* @param int $level
*
* @return string Generated variable interpolation PHP source
*/
private function variable($id, $escape, $level)
{
$filters = '';
if (isset($this->pragmas[Mustache_Engine::PRAGMA_FILTERS])) {
list($id, $filters) = $this->getFilters($id, $level);
}
$method = $this->getFindMethod($id);
$id = ($method !== 'last') ? var_export($id, true) : '';
$value = $escape ? $this->getEscape() : '$value';
return sprintf($this->prepare(self::VARIABLE, $level), $method, $id, $filters, $this->flushIndent(), $value);
}
/**
* Generate Mustache Template variable filtering PHP source.
*
* @param string $id Variable name
* @param int $level
*
* @return string Generated variable filtering PHP source
*/
private function getFilters($id, $level)
{
$filters = array_map('trim', explode('|', $id));
$id = array_shift($filters);
return array($id, $this->getFilter($filters, $level));
}
const FILTER = '
$filter = $context->%s(%s);
if (!(%s)) {
throw new Mustache_Exception_UnknownFilterException(%s);
}
$value = call_user_func($filter, $value);%s
';
/**
* Generate PHP source for a single filter.
*
* @param array $filters
* @param int $level
*
* @return string Generated filter PHP source
*/
private function getFilter(array $filters, $level)
{
if (empty($filters)) {
return '';
}
$name = array_shift($filters);
$method = $this->getFindMethod($name);
$filter = ($method !== 'last') ? var_export($name, true) : '';
$callable = $this->getCallable('$filter');
$msg = var_export($name, true);
return sprintf($this->prepare(self::FILTER, $level), $method, $filter, $callable, $msg, $this->getFilter($filters, $level));
}
const LINE = '$buffer .= "\n";';
const TEXT = '$buffer .= %s%s;';
/**
* Generate Mustache Template output Buffer call PHP source.
*
* @param string $text
* @param int $level
*
* @return string Generated output Buffer call PHP source
*/
private function text($text, $level)
{
$indentNextLine = (substr($text, -1) === "\n");
$code = sprintf($this->prepare(self::TEXT, $level), $this->flushIndent(), var_export($text, true));
$this->indentNextLine = $indentNextLine;
return $code;
}
/**
* Prepare PHP source code snippet for output.
*
* @param string $text
* @param int $bonus Additional indent level (default: 0)
* @param boolean $prependNewline Prepend a newline to the snippet? (default: true)
* @param boolean $appendNewline Append a newline to the snippet? (default: false)
*
* @return string PHP source code snippet
*/
private function prepare($text, $bonus = 0, $prependNewline = true, $appendNewline = false)
{
$text = ($prependNewline ? "\n" : '').trim($text);
if ($prependNewline) {
$bonus++;
}
if ($appendNewline) {
$text .= "\n";
}
return preg_replace("/\n( {8})?/", "\n".str_repeat(" ", $bonus * 4), $text);
}
const DEFAULT_ESCAPE = 'htmlspecialchars(%s, %s, %s)';
const CUSTOM_ESCAPE = 'call_user_func($this->mustache->getEscape(), %s)';
/**
* Get the current escaper.
*
* @param string $value (default: '$value')
*
* @return string Either a custom callback, or an inline call to `htmlspecialchars`
*/
private function getEscape($value = '$value')
{
if ($this->customEscape) {
return sprintf(self::CUSTOM_ESCAPE, $value);
} else {
return sprintf(self::DEFAULT_ESCAPE, $value, var_export($this->entityFlags, true), var_export($this->charset, true));
}
}
/**
* Select the appropriate Context `find` method for a given $id.
*
* The return value will be one of `find`, `findDot` or `last`.
*
* @see Mustache_Context::find
* @see Mustache_Context::findDot
* @see Mustache_Context::last
*
* @param string $id Variable name
*
* @return string `find` method name
*/
private function getFindMethod($id)
{
if ($id === '.') {
return 'last';
} elseif (strpos($id, '.') === false) {
return 'find';
} else {
return 'findDot';
}
}
const IS_CALLABLE = '!is_string(%s) && is_callable(%s)';
const STRICT_IS_CALLABLE = 'is_object(%s) && is_callable(%s)';
private function getCallable($variable = '$value')
{
$tpl = $this->strictCallables ? self::STRICT_IS_CALLABLE : self::IS_CALLABLE;
return sprintf($tpl, $variable, $variable);
}
const LINE_INDENT = '$indent . ';
/**
* Get the current $indent prefix to write to the buffer.
*
* @return string "$indent . " or ""
*/
private function flushIndent()
{
if (!$this->indentNextLine) {
return '';
}
$this->indentNextLine = false;
return self::LINE_INDENT;
}
}
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Mustache Compiler class.
*
* This class is responsible for turning a Mustache token parse tree into normal PHP source code.
*/
class Mustache_Compiler
{
private $sections;
private $source;
private $indentNextLine;
private $customEscape;
private $entityFlags;
private $charset;
private $strictCallables;
private $pragmas;
/**
* Compile a Mustache token parse tree into PHP source code.
*
* @param string $source Mustache Template source code
* @param string $tree Parse tree of Mustache tokens
* @param string $name Mustache Template class name
* @param bool $customEscape (default: false)
* @param int $entityFlags (default: ENT_COMPAT)
* @param string $charset (default: 'UTF-8')
* @param bool $strictCallables (default: false)
*
* @return string Generated PHP source code
*/
public function compile($source, array $tree, $name, $customEscape = false, $charset = 'UTF-8', $strictCallables = false, $entityFlags = ENT_COMPAT)
{
$this->pragmas = array();
$this->sections = array();
$this->source = $source;
$this->indentNextLine = true;
$this->customEscape = $customEscape;
$this->entityFlags = $entityFlags;
$this->charset = $charset;
$this->strictCallables = $strictCallables;
return $this->writeCode($tree, $name);
}
/**
* Helper function for walking the Mustache token parse tree.
*
* @throws Mustache_Exception_SyntaxException upon encountering unknown token types.
*
* @param array $tree Parse tree of Mustache tokens
* @param int $level (default: 0)
*
* @return string Generated PHP source code
*/
private function walk(array $tree, $level = 0)
{
$code = '';
$level++;
foreach ($tree as $node) {
switch ($node[Mustache_Tokenizer::TYPE]) {
case Mustache_Tokenizer::T_PRAGMA:
$this->pragmas[$node[Mustache_Tokenizer::NAME]] = true;
break;
case Mustache_Tokenizer::T_SECTION:
$code .= $this->section(
$node[Mustache_Tokenizer::NODES],
$node[Mustache_Tokenizer::NAME],
$node[Mustache_Tokenizer::INDEX],
$node[Mustache_Tokenizer::END],
$node[Mustache_Tokenizer::OTAG],
$node[Mustache_Tokenizer::CTAG],
$level
);
break;
case Mustache_Tokenizer::T_INVERTED:
$code .= $this->invertedSection(
$node[Mustache_Tokenizer::NODES],
$node[Mustache_Tokenizer::NAME],
$level
);
break;
case Mustache_Tokenizer::T_PARTIAL:
case Mustache_Tokenizer::T_PARTIAL_2:
$code .= $this->partial(
$node[Mustache_Tokenizer::NAME],
isset($node[Mustache_Tokenizer::INDENT]) ? $node[Mustache_Tokenizer::INDENT] : '',
$level
);
break;
case Mustache_Tokenizer::T_UNESCAPED:
case Mustache_Tokenizer::T_UNESCAPED_2:
$code .= $this->variable($node[Mustache_Tokenizer::NAME], false, $level);
break;
case Mustache_Tokenizer::T_COMMENT:
break;
case Mustache_Tokenizer::T_ESCAPED:
$code .= $this->variable($node[Mustache_Tokenizer::NAME], true, $level);
break;
case Mustache_Tokenizer::T_TEXT:
$code .= $this->text($node[Mustache_Tokenizer::VALUE], $level);
break;
default:
throw new Mustache_Exception_SyntaxException(sprintf('Unknown token type: %s', $node[Mustache_Tokenizer::TYPE]), $node);
}
}
return $code;
}
const KLASS = '<?php
class %s extends Mustache_Template
{
private $lambdaHelper;%s
public function renderInternal(Mustache_Context $context, $indent = \'\')
{
$this->lambdaHelper = new Mustache_LambdaHelper($this->mustache, $context);
$buffer = \'\';
%s
return $buffer;
}
%s
}';
const KLASS_NO_LAMBDAS = '<?php
class %s extends Mustache_Template
{%s
public function renderInternal(Mustache_Context $context, $indent = \'\')
{
$buffer = \'\';
%s
return $buffer;
}
}';
const STRICT_CALLABLE = 'protected $strictCallables = true;';
/**
* Generate Mustache Template class PHP source.
*
* @param array $tree Parse tree of Mustache tokens
* @param string $name Mustache Template class name
*
* @return string Generated PHP source code
*/
private function writeCode($tree, $name)
{
$code = $this->walk($tree);
$sections = implode("\n", $this->sections);
$klass = empty($this->sections) ? self::KLASS_NO_LAMBDAS : self::KLASS;
$callable = $this->strictCallables ? $this->prepare(self::STRICT_CALLABLE) : '';
return sprintf($this->prepare($klass, 0, false, true), $name, $callable, $code, $sections);
}
const SECTION_CALL = '
// %s section
$buffer .= $this->section%s($context, $indent, $context->%s(%s));
';
const SECTION = '
private function section%s(Mustache_Context $context, $indent, $value)
{
$buffer = \'\';
if (%s) {
$source = %s;
$buffer .= $this->mustache
->loadLambda((string) call_user_func($value, $source, $this->lambdaHelper)%s)
->renderInternal($context);
} elseif (!empty($value)) {
$values = $this->isIterable($value) ? $value : array($value);
foreach ($values as $value) {
$context->push($value);%s
$context->pop();
}
}
return $buffer;
}';
/**
* Generate Mustache Template section PHP source.
*
* @param array $nodes Array of child tokens
* @param string $id Section name
* @param int $start Section start offset
* @param int $end Section end offset
* @param string $otag Current Mustache opening tag
* @param string $ctag Current Mustache closing tag
* @param int $level
*
* @return string Generated section PHP source code
*/
private function section($nodes, $id, $start, $end, $otag, $ctag, $level)
{
$method = $this->getFindMethod($id);
$id = var_export($id, true);
$source = var_export(substr($this->source, $start, $end - $start), true);
$callable = $this->getCallable();
if ($otag !== '{{' || $ctag !== '}}') {
$delims = ', '.var_export(sprintf('{{= %s %s =}}', $otag, $ctag), true);
} else {
$delims = '';
}
$key = ucfirst(md5($delims."\n".$source));
if (!isset($this->sections[$key])) {
$this->sections[$key] = sprintf($this->prepare(self::SECTION), $key, $callable, $source, $delims, $this->walk($nodes, 2));
}
return sprintf($this->prepare(self::SECTION_CALL, $level), $id, $key, $method, $id);
}
const INVERTED_SECTION = '
// %s inverted section
$value = $context->%s(%s);
if (empty($value)) {
%s
}';
/**
* Generate Mustache Template inverted section PHP source.
*
* @param array $nodes Array of child tokens
* @param string $id Section name
* @param int $level
*
* @return string Generated inverted section PHP source code
*/
private function invertedSection($nodes, $id, $level)
{
$method = $this->getFindMethod($id);
$id = var_export($id, true);
return sprintf($this->prepare(self::INVERTED_SECTION, $level), $id, $method, $id, $this->walk($nodes, $level));
}
const PARTIAL = '
if ($partial = $this->mustache->loadPartial(%s)) {
$buffer .= $partial->renderInternal($context, %s);
}
';
/**
* Generate Mustache Template partial call PHP source.
*
* @param string $id Partial name
* @param string $indent Whitespace indent to apply to partial
* @param int $level
*
* @return string Generated partial call PHP source code
*/
private function partial($id, $indent, $level)
{
return sprintf(
$this->prepare(self::PARTIAL, $level),
var_export($id, true),
var_export($indent, true)
);
}
const VARIABLE = '
$value = $this->resolveValue($context->%s(%s), $context, $indent);%s
$buffer .= %s%s;
';
/**
* Generate Mustache Template variable interpolation PHP source.
*
* @param string $id Variable name
* @param boolean $escape Escape the variable value for output?
* @param int $level
*
* @return string Generated variable interpolation PHP source
*/
private function variable($id, $escape, $level)
{
$filters = '';
if (isset($this->pragmas[Mustache_Engine::PRAGMA_FILTERS])) {
list($id, $filters) = $this->getFilters($id, $level);
}
$method = $this->getFindMethod($id);
$id = ($method !== 'last') ? var_export($id, true) : '';
$value = $escape ? $this->getEscape() : '$value';
return sprintf($this->prepare(self::VARIABLE, $level), $method, $id, $filters, $this->flushIndent(), $value);
}
/**
* Generate Mustache Template variable filtering PHP source.
*
* @param string $id Variable name
* @param int $level
*
* @return string Generated variable filtering PHP source
*/
private function getFilters($id, $level)
{
$filters = array_map('trim', explode('|', $id));
$id = array_shift($filters);
return array($id, $this->getFilter($filters, $level));
}
const FILTER = '
$filter = $context->%s(%s);
if (!(%s)) {
throw new Mustache_Exception_UnknownFilterException(%s);
}
$value = call_user_func($filter, $value);%s
';
/**
* Generate PHP source for a single filter.
*
* @param array $filters
* @param int $level
*
* @return string Generated filter PHP source
*/
private function getFilter(array $filters, $level)
{
if (empty($filters)) {
return '';
}
$name = array_shift($filters);
$method = $this->getFindMethod($name);
$filter = ($method !== 'last') ? var_export($name, true) : '';
$callable = $this->getCallable('$filter');
$msg = var_export($name, true);
return sprintf($this->prepare(self::FILTER, $level), $method, $filter, $callable, $msg, $this->getFilter($filters, $level));
}
const LINE = '$buffer .= "\n";';
const TEXT = '$buffer .= %s%s;';
/**
* Generate Mustache Template output Buffer call PHP source.
*
* @param string $text
* @param int $level
*
* @return string Generated output Buffer call PHP source
*/
private function text($text, $level)
{
$indentNextLine = (substr($text, -1) === "\n");
$code = sprintf($this->prepare(self::TEXT, $level), $this->flushIndent(), var_export($text, true));
$this->indentNextLine = $indentNextLine;
return $code;
}
/**
* Prepare PHP source code snippet for output.
*
* @param string $text
* @param int $bonus Additional indent level (default: 0)
* @param boolean $prependNewline Prepend a newline to the snippet? (default: true)
* @param boolean $appendNewline Append a newline to the snippet? (default: false)
*
* @return string PHP source code snippet
*/
private function prepare($text, $bonus = 0, $prependNewline = true, $appendNewline = false)
{
$text = ($prependNewline ? "\n" : '').trim($text);
if ($prependNewline) {
$bonus++;
}
if ($appendNewline) {
$text .= "\n";
}
return preg_replace("/\n( {8})?/", "\n".str_repeat(" ", $bonus * 4), $text);
}
const DEFAULT_ESCAPE = 'htmlspecialchars(%s, %s, %s)';
const CUSTOM_ESCAPE = 'call_user_func($this->mustache->getEscape(), %s)';
/**
* Get the current escaper.
*
* @param string $value (default: '$value')
*
* @return string Either a custom callback, or an inline call to `htmlspecialchars`
*/
private function getEscape($value = '$value')
{
if ($this->customEscape) {
return sprintf(self::CUSTOM_ESCAPE, $value);
} else {
return sprintf(self::DEFAULT_ESCAPE, $value, var_export($this->entityFlags, true), var_export($this->charset, true));
}
}
/**
* Select the appropriate Context `find` method for a given $id.
*
* The return value will be one of `find`, `findDot` or `last`.
*
* @see Mustache_Context::find
* @see Mustache_Context::findDot
* @see Mustache_Context::last
*
* @param string $id Variable name
*
* @return string `find` method name
*/
private function getFindMethod($id)
{
if ($id === '.') {
return 'last';
} elseif (strpos($id, '.') === false) {
return 'find';
} else {
return 'findDot';
}
}
const IS_CALLABLE = '!is_string(%s) && is_callable(%s)';
const STRICT_IS_CALLABLE = 'is_object(%s) && is_callable(%s)';
private function getCallable($variable = '$value')
{
$tpl = $this->strictCallables ? self::STRICT_IS_CALLABLE : self::IS_CALLABLE;
return sprintf($tpl, $variable, $variable);
}
const LINE_INDENT = '$indent . ';
/**
* Get the current $indent prefix to write to the buffer.
*
* @return string "$indent . " or ""
*/
private function flushIndent()
{
if (!$this->indentNextLine) {
return '';
}
$this->indentNextLine = false;
return self::LINE_INDENT;
}
}

View File

@ -1,149 +1,149 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Mustache Template rendering Context.
*/
class Mustache_Context
{
private $stack = array();
/**
* Mustache rendering Context constructor.
*
* @param mixed $context Default rendering context (default: null)
*/
public function __construct($context = null)
{
if ($context !== null) {
$this->stack = array($context);
}
}
/**
* Push a new Context frame onto the stack.
*
* @param mixed $value Object or array to use for context
*/
public function push($value)
{
array_push($this->stack, $value);
}
/**
* Pop the last Context frame from the stack.
*
* @return mixed Last Context frame (object or array)
*/
public function pop()
{
return array_pop($this->stack);
}
/**
* Get the last Context frame.
*
* @return mixed Last Context frame (object or array)
*/
public function last()
{
return end($this->stack);
}
/**
* Find a variable in the Context stack.
*
* Starting with the last Context frame (the context of the innermost section), and working back to the top-level
* rendering context, look for a variable with the given name:
*
* * If the Context frame is an associative array which contains the key $id, returns the value of that element.
* * If the Context frame is an object, this will check first for a public method, then a public property named
* $id. Failing both of these, it will try `__isset` and `__get` magic methods.
* * If a value named $id is not found in any Context frame, returns an empty string.
*
* @param string $id Variable name
*
* @return mixed Variable value, or '' if not found
*/
public function find($id)
{
return $this->findVariableInStack($id, $this->stack);
}
/**
* Find a 'dot notation' variable in the Context stack.
*
* Note that dot notation traversal bubbles through scope differently than the regular find method. After finding
* the initial chunk of the dotted name, each subsequent chunk is searched for only within the value of the previous
* result. For example, given the following context stack:
*
* $data = array(
* 'name' => 'Fred',
* 'child' => array(
* 'name' => 'Bob'
* ),
* );
*
* ... and the Mustache following template:
*
* {{ child.name }}
*
* ... the `name` value is only searched for within the `child` value of the global Context, not within parent
* Context frames.
*
* @param string $id Dotted variable selector
*
* @return mixed Variable value, or '' if not found
*/
public function findDot($id)
{
$chunks = explode('.', $id);
$first = array_shift($chunks);
$value = $this->findVariableInStack($first, $this->stack);
foreach ($chunks as $chunk) {
if ($value === '') {
return $value;
}
$value = $this->findVariableInStack($chunk, array($value));
}
return $value;
}
/**
* Helper function to find a variable in the Context stack.
*
* @see Mustache_Context::find
*
* @param string $id Variable name
* @param array $stack Context stack
*
* @return mixed Variable value, or '' if not found
*/
private function findVariableInStack($id, array $stack)
{
for ($i = count($stack) - 1; $i >= 0; $i--) {
if (is_object($stack[$i]) && !$stack[$i] instanceof Closure) {
if (method_exists($stack[$i], $id)) {
return $stack[$i]->$id();
} elseif (isset($stack[$i]->$id)) {
return $stack[$i]->$id;
}
} elseif (is_array($stack[$i]) && array_key_exists($id, $stack[$i])) {
return $stack[$i][$id];
}
}
return '';
}
}
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Mustache Template rendering Context.
*/
class Mustache_Context
{
private $stack = array();
/**
* Mustache rendering Context constructor.
*
* @param mixed $context Default rendering context (default: null)
*/
public function __construct($context = null)
{
if ($context !== null) {
$this->stack = array($context);
}
}
/**
* Push a new Context frame onto the stack.
*
* @param mixed $value Object or array to use for context
*/
public function push($value)
{
array_push($this->stack, $value);
}
/**
* Pop the last Context frame from the stack.
*
* @return mixed Last Context frame (object or array)
*/
public function pop()
{
return array_pop($this->stack);
}
/**
* Get the last Context frame.
*
* @return mixed Last Context frame (object or array)
*/
public function last()
{
return end($this->stack);
}
/**
* Find a variable in the Context stack.
*
* Starting with the last Context frame (the context of the innermost section), and working back to the top-level
* rendering context, look for a variable with the given name:
*
* * If the Context frame is an associative array which contains the key $id, returns the value of that element.
* * If the Context frame is an object, this will check first for a public method, then a public property named
* $id. Failing both of these, it will try `__isset` and `__get` magic methods.
* * If a value named $id is not found in any Context frame, returns an empty string.
*
* @param string $id Variable name
*
* @return mixed Variable value, or '' if not found
*/
public function find($id)
{
return $this->findVariableInStack($id, $this->stack);
}
/**
* Find a 'dot notation' variable in the Context stack.
*
* Note that dot notation traversal bubbles through scope differently than the regular find method. After finding
* the initial chunk of the dotted name, each subsequent chunk is searched for only within the value of the previous
* result. For example, given the following context stack:
*
* $data = array(
* 'name' => 'Fred',
* 'child' => array(
* 'name' => 'Bob'
* ),
* );
*
* ... and the Mustache following template:
*
* {{ child.name }}
*
* ... the `name` value is only searched for within the `child` value of the global Context, not within parent
* Context frames.
*
* @param string $id Dotted variable selector
*
* @return mixed Variable value, or '' if not found
*/
public function findDot($id)
{
$chunks = explode('.', $id);
$first = array_shift($chunks);
$value = $this->findVariableInStack($first, $this->stack);
foreach ($chunks as $chunk) {
if ($value === '') {
return $value;
}
$value = $this->findVariableInStack($chunk, array($value));
}
return $value;
}
/**
* Helper function to find a variable in the Context stack.
*
* @see Mustache_Context::find
*
* @param string $id Variable name
* @param array $stack Context stack
*
* @return mixed Variable value, or '' if not found
*/
private function findVariableInStack($id, array $stack)
{
for ($i = count($stack) - 1; $i >= 0; $i--) {
if (is_object($stack[$i]) && !$stack[$i] instanceof Closure) {
if (method_exists($stack[$i], $id)) {
return $stack[$i]->$id();
} elseif (isset($stack[$i]->$id)) {
return $stack[$i]->$id;
}
} elseif (is_array($stack[$i]) && array_key_exists($id, $stack[$i])) {
return $stack[$i][$id];
}
}
return '';
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,18 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2013 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* A Mustache Exception interface.
*/
interface Mustache_Exception
{
// This space intentionally left blank.
}
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2013 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* A Mustache Exception interface.
*/
interface Mustache_Exception
{
// This space intentionally left blank.
}

View File

@ -1,18 +1,18 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2013 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Invalid argument exception.
*/
class Mustache_Exception_InvalidArgumentException extends InvalidArgumentException implements Mustache_Exception
{
// This space intentionally left blank.
}
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2013 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Invalid argument exception.
*/
class Mustache_Exception_InvalidArgumentException extends InvalidArgumentException implements Mustache_Exception
{
// This space intentionally left blank.
}

View File

@ -1,18 +1,18 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2013 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Logic exception.
*/
class Mustache_Exception_LogicException extends LogicException implements Mustache_Exception
{
// This space intentionally left blank.
}
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2013 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Logic exception.
*/
class Mustache_Exception_LogicException extends LogicException implements Mustache_Exception
{
// This space intentionally left blank.
}

View File

@ -1,18 +1,18 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2013 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Runtime exception.
*/
class Mustache_Exception_RuntimeException extends RuntimeException implements Mustache_Exception
{
// This space intentionally left blank.
}
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2013 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Runtime exception.
*/
class Mustache_Exception_RuntimeException extends RuntimeException implements Mustache_Exception
{
// This space intentionally left blank.
}

View File

@ -1,29 +1,29 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2013 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Mustache syntax exception.
*/
class Mustache_Exception_SyntaxException extends LogicException implements Mustache_Exception
{
protected $token;
public function __construct($msg, array $token)
{
$this->token = $token;
parent::__construct($msg);
}
public function getToken()
{
return $this->token;
}
}
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2013 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Mustache syntax exception.
*/
class Mustache_Exception_SyntaxException extends LogicException implements Mustache_Exception
{
protected $token;
public function __construct($msg, array $token)
{
$this->token = $token;
parent::__construct($msg);
}
public function getToken()
{
return $this->token;
}
}

View File

@ -1,29 +1,29 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2013 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Unknown filter exception.
*/
class Mustache_Exception_UnknownFilterException extends UnexpectedValueException implements Mustache_Exception
{
protected $filterName;
public function __construct($filterName)
{
$this->filterName = $filterName;
parent::__construct(sprintf('Unknown filter: %s', $filterName));
}
public function getFilterName()
{
return $this->filterName;
}
}
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2013 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Unknown filter exception.
*/
class Mustache_Exception_UnknownFilterException extends UnexpectedValueException implements Mustache_Exception
{
protected $filterName;
public function __construct($filterName)
{
$this->filterName = $filterName;
parent::__construct(sprintf('Unknown filter: %s', $filterName));
}
public function getFilterName()
{
return $this->filterName;
}
}

View File

@ -1,29 +1,29 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2013 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Unknown helper exception.
*/
class Mustache_Exception_UnknownHelperException extends InvalidArgumentException implements Mustache_Exception
{
protected $helperName;
public function __construct($helperName)
{
$this->helperName = $helperName;
parent::__construct(sprintf('Unknown helper: %s', $helperName));
}
public function getHelperName()
{
return $this->helperName;
}
}
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2013 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Unknown helper exception.
*/
class Mustache_Exception_UnknownHelperException extends InvalidArgumentException implements Mustache_Exception
{
protected $helperName;
public function __construct($helperName)
{
$this->helperName = $helperName;
parent::__construct(sprintf('Unknown helper: %s', $helperName));
}
public function getHelperName()
{
return $this->helperName;
}
}

View File

@ -1,29 +1,29 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2013 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Unknown template exception.
*/
class Mustache_Exception_UnknownTemplateException extends InvalidArgumentException implements Mustache_Exception
{
protected $templateName;
public function __construct($templateName)
{
$this->templateName = $templateName;
parent::__construct(sprintf('Unknown template: %s', $templateName));
}
public function getTemplateName()
{
return $this->templateName;
}
}
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2013 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Unknown template exception.
*/
class Mustache_Exception_UnknownTemplateException extends InvalidArgumentException implements Mustache_Exception
{
protected $templateName;
public function __construct($templateName)
{
$this->templateName = $templateName;
parent::__construct(sprintf('Unknown template: %s', $templateName));
}
public function getTemplateName()
{
return $this->templateName;
}
}

View File

@ -1,170 +1,170 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* A collection of helpers for a Mustache instance.
*/
class Mustache_HelperCollection
{
private $helpers = array();
/**
* Helper Collection constructor.
*
* Optionally accepts an array (or Traversable) of `$name => $helper` pairs.
*
* @throws Mustache_Exception_InvalidArgumentException if the $helpers argument isn't an array or Traversable
*
* @param array|Traversable $helpers (default: null)
*/
public function __construct($helpers = null)
{
if ($helpers !== null) {
if (!is_array($helpers) && !$helpers instanceof Traversable) {
throw new Mustache_Exception_InvalidArgumentException('HelperCollection constructor expects an array of helpers');
}
foreach ($helpers as $name => $helper) {
$this->add($name, $helper);
}
}
}
/**
* Magic mutator.
*
* @see Mustache_HelperCollection::add
*
* @param string $name
* @param mixed $helper
*/
public function __set($name, $helper)
{
$this->add($name, $helper);
}
/**
* Add a helper to this collection.
*
* @param string $name
* @param mixed $helper
*/
public function add($name, $helper)
{
$this->helpers[$name] = $helper;
}
/**
* Magic accessor.
*
* @see Mustache_HelperCollection::get
*
* @param string $name
*
* @return mixed Helper
*/
public function __get($name)
{
return $this->get($name);
}
/**
* Get a helper by name.
*
* @throws Mustache_Exception_UnknownHelperException If helper does not exist.
*
* @param string $name
*
* @return mixed Helper
*/
public function get($name)
{
if (!$this->has($name)) {
throw new Mustache_Exception_UnknownHelperException($name);
}
return $this->helpers[$name];
}
/**
* Magic isset().
*
* @see Mustache_HelperCollection::has
*
* @param string $name
*
* @return boolean True if helper is present
*/
public function __isset($name)
{
return $this->has($name);
}
/**
* Check whether a given helper is present in the collection.
*
* @param string $name
*
* @return boolean True if helper is present
*/
public function has($name)
{
return array_key_exists($name, $this->helpers);
}
/**
* Magic unset().
*
* @see Mustache_HelperCollection::remove
*
* @param string $name
*/
public function __unset($name)
{
$this->remove($name);
}
/**
* Check whether a given helper is present in the collection.
*
* @throws Mustache_Exception_UnknownHelperException if the requested helper is not present.
*
* @param string $name
*/
public function remove($name)
{
if (!$this->has($name)) {
throw new Mustache_Exception_UnknownHelperException($name);
}
unset($this->helpers[$name]);
}
/**
* Clear the helper collection.
*
* Removes all helpers from this collection
*/
public function clear()
{
$this->helpers = array();
}
/**
* Check whether the helper collection is empty.
*
* @return boolean True if the collection is empty
*/
public function isEmpty()
{
return empty($this->helpers);
}
}
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* A collection of helpers for a Mustache instance.
*/
class Mustache_HelperCollection
{
private $helpers = array();
/**
* Helper Collection constructor.
*
* Optionally accepts an array (or Traversable) of `$name => $helper` pairs.
*
* @throws Mustache_Exception_InvalidArgumentException if the $helpers argument isn't an array or Traversable
*
* @param array|Traversable $helpers (default: null)
*/
public function __construct($helpers = null)
{
if ($helpers !== null) {
if (!is_array($helpers) && !$helpers instanceof Traversable) {
throw new Mustache_Exception_InvalidArgumentException('HelperCollection constructor expects an array of helpers');
}
foreach ($helpers as $name => $helper) {
$this->add($name, $helper);
}
}
}
/**
* Magic mutator.
*
* @see Mustache_HelperCollection::add
*
* @param string $name
* @param mixed $helper
*/
public function __set($name, $helper)
{
$this->add($name, $helper);
}
/**
* Add a helper to this collection.
*
* @param string $name
* @param mixed $helper
*/
public function add($name, $helper)
{
$this->helpers[$name] = $helper;
}
/**
* Magic accessor.
*
* @see Mustache_HelperCollection::get
*
* @param string $name
*
* @return mixed Helper
*/
public function __get($name)
{
return $this->get($name);
}
/**
* Get a helper by name.
*
* @throws Mustache_Exception_UnknownHelperException If helper does not exist.
*
* @param string $name
*
* @return mixed Helper
*/
public function get($name)
{
if (!$this->has($name)) {
throw new Mustache_Exception_UnknownHelperException($name);
}
return $this->helpers[$name];
}
/**
* Magic isset().
*
* @see Mustache_HelperCollection::has
*
* @param string $name
*
* @return boolean True if helper is present
*/
public function __isset($name)
{
return $this->has($name);
}
/**
* Check whether a given helper is present in the collection.
*
* @param string $name
*
* @return boolean True if helper is present
*/
public function has($name)
{
return array_key_exists($name, $this->helpers);
}
/**
* Magic unset().
*
* @see Mustache_HelperCollection::remove
*
* @param string $name
*/
public function __unset($name)
{
$this->remove($name);
}
/**
* Check whether a given helper is present in the collection.
*
* @throws Mustache_Exception_UnknownHelperException if the requested helper is not present.
*
* @param string $name
*/
public function remove($name)
{
if (!$this->has($name)) {
throw new Mustache_Exception_UnknownHelperException($name);
}
unset($this->helpers[$name]);
}
/**
* Clear the helper collection.
*
* Removes all helpers from this collection
*/
public function clear()
{
$this->helpers = array();
}
/**
* Check whether the helper collection is empty.
*
* @return boolean True if the collection is empty
*/
public function isEmpty()
{
return empty($this->helpers);
}
}

View File

@ -1,49 +1,49 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Mustache Lambda Helper.
*
* Passed as the second argument to section lambdas (higher order sections),
* giving them access to a `render` method for rendering a string with the
* current context.
*/
class Mustache_LambdaHelper
{
private $mustache;
private $context;
/**
* Mustache Lambda Helper constructor.
*
* @param Mustache_Engine $mustache Mustache engine instance.
* @param Mustache_Context $context Rendering context.
*/
public function __construct(Mustache_Engine $mustache, Mustache_Context $context)
{
$this->mustache = $mustache;
$this->context = $context;
}
/**
* Render a string as a Mustache template with the current rendering context.
*
* @param string $string
*
* @return Rendered template.
*/
public function render($string)
{
return $this->mustache
->loadLambda((string) $string)
->renderInternal($this->context);
}
}
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Mustache Lambda Helper.
*
* Passed as the second argument to section lambdas (higher order sections),
* giving them access to a `render` method for rendering a string with the
* current context.
*/
class Mustache_LambdaHelper
{
private $mustache;
private $context;
/**
* Mustache Lambda Helper constructor.
*
* @param Mustache_Engine $mustache Mustache engine instance.
* @param Mustache_Context $context Rendering context.
*/
public function __construct(Mustache_Engine $mustache, Mustache_Context $context)
{
$this->mustache = $mustache;
$this->context = $context;
}
/**
* Render a string as a Mustache template with the current rendering context.
*
* @param string $string
*
* @return Rendered template.
*/
public function render($string)
{
return $this->mustache
->loadLambda((string) $string)
->renderInternal($this->context);
}
}

View File

@ -1,28 +1,28 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Mustache Template Loader interface.
*/
interface Mustache_Loader
{
/**
* Load a Template by name.
*
* @throws Mustache_Exception_UnknownTemplateException If a template file is not found.
*
* @param string $name
*
* @return string Mustache Template source
*/
public function load($name);
}
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Mustache Template Loader interface.
*/
interface Mustache_Loader
{
/**
* Load a Template by name.
*
* @throws Mustache_Exception_UnknownTemplateException If a template file is not found.
*
* @param string $name
*
* @return string Mustache Template source
*/
public function load($name);
}

View File

@ -1,78 +1,78 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Mustache Template array Loader implementation.
*
* An ArrayLoader instance loads Mustache Template source by name from an initial array:
*
* $loader = new ArrayLoader(
* 'foo' => '{{ bar }}',
* 'baz' => 'Hey {{ qux }}!'
* );
*
* $tpl = $loader->load('foo'); // '{{ bar }}'
*
* The ArrayLoader is used internally as a partials loader by Mustache_Engine instance when an array of partials
* is set. It can also be used as a quick-and-dirty Template loader.
*/
class Mustache_Loader_ArrayLoader implements Mustache_Loader, Mustache_Loader_MutableLoader
{
/**
* ArrayLoader constructor.
*
* @param array $templates Associative array of Template source (default: array())
*/
public function __construct(array $templates = array())
{
$this->templates = $templates;
}
/**
* Load a Template.
*
* @throws Mustache_Exception_UnknownTemplateException If a template file is not found.
*
* @param string $name
*
* @return string Mustache Template source
*/
public function load($name)
{
if (!isset($this->templates[$name])) {
throw new Mustache_Exception_UnknownTemplateException($name);
}
return $this->templates[$name];
}
/**
* Set an associative array of Template sources for this loader.
*
* @param array $templates
*/
public function setTemplates(array $templates)
{
$this->templates = $templates;
}
/**
* Set a Template source by name.
*
* @param string $name
* @param string $template Mustache Template source
*/
public function setTemplate($name, $template)
{
$this->templates[$name] = $template;
}
}
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Mustache Template array Loader implementation.
*
* An ArrayLoader instance loads Mustache Template source by name from an initial array:
*
* $loader = new ArrayLoader(
* 'foo' => '{{ bar }}',
* 'baz' => 'Hey {{ qux }}!'
* );
*
* $tpl = $loader->load('foo'); // '{{ bar }}'
*
* The ArrayLoader is used internally as a partials loader by Mustache_Engine instance when an array of partials
* is set. It can also be used as a quick-and-dirty Template loader.
*/
class Mustache_Loader_ArrayLoader implements Mustache_Loader, Mustache_Loader_MutableLoader
{
/**
* ArrayLoader constructor.
*
* @param array $templates Associative array of Template source (default: array())
*/
public function __construct(array $templates = array())
{
$this->templates = $templates;
}
/**
* Load a Template.
*
* @throws Mustache_Exception_UnknownTemplateException If a template file is not found.
*
* @param string $name
*
* @return string Mustache Template source
*/
public function load($name)
{
if (!isset($this->templates[$name])) {
throw new Mustache_Exception_UnknownTemplateException($name);
}
return $this->templates[$name];
}
/**
* Set an associative array of Template sources for this loader.
*
* @param array $templates
*/
public function setTemplates(array $templates)
{
$this->templates = $templates;
}
/**
* Set a Template source by name.
*
* @param string $name
* @param string $template Mustache Template source
*/
public function setTemplate($name, $template)
{
$this->templates[$name] = $template;
}
}

View File

@ -1,69 +1,69 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2013 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* A Mustache Template cascading loader implementation, which delegates to other
* Loader instances.
*/
class Mustache_Loader_CascadingLoader implements Mustache_Loader
{
private $loaders;
/**
* Construct a CascadingLoader with an array of loaders:
*
* $loader = new Mustache_Loader_CascadingLoader(array(
* new Mustache_Loader_InlineLoader(__FILE__, __COMPILER_HALT_OFFSET__),
* new Mustache_Loader_FilesystemLoader(__DIR__.'/templates')
* ));
*
* @param array $loaders An array of Mustache Loader instances
*/
public function __construct(array $loaders = array())
{
$this->loaders = array();
foreach ($loaders as $loader) {
$this->addLoader($loader);
}
}
/**
* Add a Loader instance.
*
* @param Mustache_Loader $loader A Mustache Loader instance
*/
public function addLoader(Mustache_Loader $loader)
{
$this->loaders[] = $loader;
}
/**
* Load a Template by name.
*
* @throws Mustache_Exception_UnknownTemplateException If a template file is not found.
*
* @param string $name
*
* @return string Mustache Template source
*/
public function load($name)
{
foreach ($this->loaders as $loader) {
try {
return $loader->load($name);
} catch (Mustache_Exception_UnknownTemplateException $e) {
// do nothing, check the next loader.
}
}
throw new Mustache_Exception_UnknownTemplateException($name);
}
}
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2013 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* A Mustache Template cascading loader implementation, which delegates to other
* Loader instances.
*/
class Mustache_Loader_CascadingLoader implements Mustache_Loader
{
private $loaders;
/**
* Construct a CascadingLoader with an array of loaders:
*
* $loader = new Mustache_Loader_CascadingLoader(array(
* new Mustache_Loader_InlineLoader(__FILE__, __COMPILER_HALT_OFFSET__),
* new Mustache_Loader_FilesystemLoader(__DIR__.'/templates')
* ));
*
* @param array $loaders An array of Mustache Loader instances
*/
public function __construct(array $loaders = array())
{
$this->loaders = array();
foreach ($loaders as $loader) {
$this->addLoader($loader);
}
}
/**
* Add a Loader instance.
*
* @param Mustache_Loader $loader A Mustache Loader instance
*/
public function addLoader(Mustache_Loader $loader)
{
$this->loaders[] = $loader;
}
/**
* Load a Template by name.
*
* @throws Mustache_Exception_UnknownTemplateException If a template file is not found.
*
* @param string $name
*
* @return string Mustache Template source
*/
public function load($name)
{
foreach ($this->loaders as $loader) {
try {
return $loader->load($name);
} catch (Mustache_Exception_UnknownTemplateException $e) {
// do nothing, check the next loader.
}
}
throw new Mustache_Exception_UnknownTemplateException($name);
}
}

View File

@ -1,124 +1,124 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Mustache Template filesystem Loader implementation.
*
* A FilesystemLoader instance loads Mustache Template source from the filesystem by name:
*
* $loader = new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views');
* $tpl = $loader->load('foo'); // equivalent to `file_get_contents(dirname(__FILE__).'/views/foo.mustache');
*
* This is probably the most useful Mustache Loader implementation. It can be used for partials and normal Templates:
*
* $m = new Mustache(array(
* 'loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views'),
* 'partials_loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views/partials'),
* ));
*/
class Mustache_Loader_FilesystemLoader implements Mustache_Loader
{
private $baseDir;
private $extension = '.mustache';
private $templates = array();
/**
* Mustache filesystem Loader constructor.
*
* Passing an $options array allows overriding certain Loader options during instantiation:
*
* $options = array(
* // The filename extension used for Mustache templates. Defaults to '.mustache'
* 'extension' => '.ms',
* );
*
* @throws Mustache_Exception_RuntimeException if $baseDir does not exist.
*
* @param string $baseDir Base directory containing Mustache template files.
* @param array $options Array of Loader options (default: array())
*/
public function __construct($baseDir, array $options = array())
{
$this->baseDir = $baseDir;
if (strpos($this->baseDir, '://') === -1) {
$this->baseDir = realpath($this->baseDir);
}
if (!is_dir($this->baseDir)) {
throw new Mustache_Exception_RuntimeException(sprintf('FilesystemLoader baseDir must be a directory: %s', $baseDir));
}
if (array_key_exists('extension', $options)) {
if (empty($options['extension'])) {
$this->extension = '';
} else {
$this->extension = '.' . ltrim($options['extension'], '.');
}
}
}
/**
* Load a Template by name.
*
* $loader = new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views');
* $loader->load('admin/dashboard'); // loads "./views/admin/dashboard.mustache";
*
* @param string $name
*
* @return string Mustache Template source
*/
public function load($name)
{
if (!isset($this->templates[$name])) {
$this->templates[$name] = $this->loadFile($name);
}
return $this->templates[$name];
}
/**
* Helper function for loading a Mustache file by name.
*
* @throws Mustache_Exception_UnknownTemplateException If a template file is not found.
*
* @param string $name
*
* @return string Mustache Template source
*/
protected function loadFile($name)
{
$fileName = $this->getFileName($name);
if (!file_exists($fileName)) {
throw new Mustache_Exception_UnknownTemplateException($name);
}
return file_get_contents($fileName);
}
/**
* Helper function for getting a Mustache template file name.
*
* @param string $name
*
* @return string Template file name
*/
protected function getFileName($name)
{
$fileName = $this->baseDir . '/' . $name;
if (substr($fileName, 0 - strlen($this->extension)) !== $this->extension) {
$fileName .= $this->extension;
}
return $fileName;
}
}
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Mustache Template filesystem Loader implementation.
*
* A FilesystemLoader instance loads Mustache Template source from the filesystem by name:
*
* $loader = new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views');
* $tpl = $loader->load('foo'); // equivalent to `file_get_contents(dirname(__FILE__).'/views/foo.mustache');
*
* This is probably the most useful Mustache Loader implementation. It can be used for partials and normal Templates:
*
* $m = new Mustache(array(
* 'loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views'),
* 'partials_loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views/partials'),
* ));
*/
class Mustache_Loader_FilesystemLoader implements Mustache_Loader
{
private $baseDir;
private $extension = '.mustache';
private $templates = array();
/**
* Mustache filesystem Loader constructor.
*
* Passing an $options array allows overriding certain Loader options during instantiation:
*
* $options = array(
* // The filename extension used for Mustache templates. Defaults to '.mustache'
* 'extension' => '.ms',
* );
*
* @throws Mustache_Exception_RuntimeException if $baseDir does not exist.
*
* @param string $baseDir Base directory containing Mustache template files.
* @param array $options Array of Loader options (default: array())
*/
public function __construct($baseDir, array $options = array())
{
$this->baseDir = $baseDir;
if (strpos($this->baseDir, '://') === -1) {
$this->baseDir = realpath($this->baseDir);
}
if (!is_dir($this->baseDir)) {
throw new Mustache_Exception_RuntimeException(sprintf('FilesystemLoader baseDir must be a directory: %s', $baseDir));
}
if (array_key_exists('extension', $options)) {
if (empty($options['extension'])) {
$this->extension = '';
} else {
$this->extension = '.' . ltrim($options['extension'], '.');
}
}
}
/**
* Load a Template by name.
*
* $loader = new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views');
* $loader->load('admin/dashboard'); // loads "./views/admin/dashboard.mustache";
*
* @param string $name
*
* @return string Mustache Template source
*/
public function load($name)
{
if (!isset($this->templates[$name])) {
$this->templates[$name] = $this->loadFile($name);
}
return $this->templates[$name];
}
/**
* Helper function for loading a Mustache file by name.
*
* @throws Mustache_Exception_UnknownTemplateException If a template file is not found.
*
* @param string $name
*
* @return string Mustache Template source
*/
protected function loadFile($name)
{
$fileName = $this->getFileName($name);
if (!file_exists($fileName)) {
throw new Mustache_Exception_UnknownTemplateException($name);
}
return file_get_contents($fileName);
}
/**
* Helper function for getting a Mustache template file name.
*
* @param string $name
*
* @return string Template file name
*/
protected function getFileName($name)
{
$fileName = $this->baseDir . '/' . $name;
if (substr($fileName, 0 - strlen($this->extension)) !== $this->extension) {
$fileName .= $this->extension;
}
return $fileName;
}
}

View File

@ -1,123 +1,123 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2013 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* A Mustache Template loader for inline templates.
*
* With the InlineLoader, templates can be defined at the end of any PHP source
* file:
*
* $loader = new Mustache_Loader_InlineLoader(__FILE__, __COMPILER_HALT_OFFSET__);
* $hello = $loader->load('hello');
* $goodbye = $loader->load('goodbye');
*
* __halt_compiler();
*
* @@ hello
* Hello, {{ planet }}!
*
* @@ goodbye
* Goodbye, cruel {{ planet }}
*
* Templates are deliniated by lines containing only `@@ name`.
*
* The InlineLoader is well-suited to micro-frameworks such as Silex:
*
* $app->register(new MustacheServiceProvider, array(
* 'mustache.loader' => new Mustache_Loader_InlineLoader(__FILE__, __COMPILER_HALT_OFFSET__)
* ));
*
* $app->get('/{name}', function($name) use ($app) {
* return $app['mustache']->render('hello', compact('name'));
* })
* ->value('name', 'world');
*
* // ...
*
* __halt_compiler();
*
* @@ hello
* Hello, {{ name }}!
*
*/
class Mustache_Loader_InlineLoader implements Mustache_Loader
{
protected $fileName;
protected $offset;
protected $templates;
/**
* The InlineLoader requires a filename and offset to process templates.
* The magic constants `__FILE__` and `__COMPILER_HALT_OFFSET__` are usually
* perfectly suited to the job:
*
* $loader = new Mustache_Loader_InlineLoader(__FILE__, __COMPILER_HALT_OFFSET__);
*
* Note that this only works if the loader is instantiated inside the same
* file as the inline templates. If the templates are located in another
* file, it would be necessary to manually specify the filename and offset.
*
* @param string $fileName The file to parse for inline templates
* @param int $offset A string offset for the start of the templates.
* This usually coincides with the `__halt_compiler`
* call, and the `__COMPILER_HALT_OFFSET__`.
*/
public function __construct($fileName, $offset)
{
if (!is_file($fileName)) {
throw new Mustache_Exception_InvalidArgumentException('InlineLoader expects a valid filename.');
}
if (!is_int($offset) || $offset < 0) {
throw new Mustache_Exception_InvalidArgumentException('InlineLoader expects a valid file offset.');
}
$this->fileName = $fileName;
$this->offset = $offset;
}
/**
* Load a Template by name.
*
* @throws Mustache_Exception_UnknownTemplateException If a template file is not found.
*
* @param string $name
*
* @return string Mustache Template source
*/
public function load($name)
{
$this->loadTemplates();
if (!array_key_exists($name, $this->templates)) {
throw new Mustache_Exception_UnknownTemplateException($name);
}
return $this->templates[$name];
}
/**
* Parse and load templates from the end of a source file.
*/
protected function loadTemplates()
{
if ($this->templates === null) {
$this->templates = array();
$data = file_get_contents($this->fileName, false, null, $this->offset);
foreach (preg_split("/^@@(?= [\w\d\.]+$)/m", $data, -1) as $chunk) {
if (trim($chunk)) {
list($name, $content) = explode("\n", $chunk, 2);
$this->templates[trim($name)] = trim($content);
}
}
}
}
}
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2013 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* A Mustache Template loader for inline templates.
*
* With the InlineLoader, templates can be defined at the end of any PHP source
* file:
*
* $loader = new Mustache_Loader_InlineLoader(__FILE__, __COMPILER_HALT_OFFSET__);
* $hello = $loader->load('hello');
* $goodbye = $loader->load('goodbye');
*
* __halt_compiler();
*
* @@ hello
* Hello, {{ planet }}!
*
* @@ goodbye
* Goodbye, cruel {{ planet }}
*
* Templates are deliniated by lines containing only `@@ name`.
*
* The InlineLoader is well-suited to micro-frameworks such as Silex:
*
* $app->register(new MustacheServiceProvider, array(
* 'mustache.loader' => new Mustache_Loader_InlineLoader(__FILE__, __COMPILER_HALT_OFFSET__)
* ));
*
* $app->get('/{name}', function($name) use ($app) {
* return $app['mustache']->render('hello', compact('name'));
* })
* ->value('name', 'world');
*
* // ...
*
* __halt_compiler();
*
* @@ hello
* Hello, {{ name }}!
*
*/
class Mustache_Loader_InlineLoader implements Mustache_Loader
{
protected $fileName;
protected $offset;
protected $templates;
/**
* The InlineLoader requires a filename and offset to process templates.
* The magic constants `__FILE__` and `__COMPILER_HALT_OFFSET__` are usually
* perfectly suited to the job:
*
* $loader = new Mustache_Loader_InlineLoader(__FILE__, __COMPILER_HALT_OFFSET__);
*
* Note that this only works if the loader is instantiated inside the same
* file as the inline templates. If the templates are located in another
* file, it would be necessary to manually specify the filename and offset.
*
* @param string $fileName The file to parse for inline templates
* @param int $offset A string offset for the start of the templates.
* This usually coincides with the `__halt_compiler`
* call, and the `__COMPILER_HALT_OFFSET__`.
*/
public function __construct($fileName, $offset)
{
if (!is_file($fileName)) {
throw new Mustache_Exception_InvalidArgumentException('InlineLoader expects a valid filename.');
}
if (!is_int($offset) || $offset < 0) {
throw new Mustache_Exception_InvalidArgumentException('InlineLoader expects a valid file offset.');
}
$this->fileName = $fileName;
$this->offset = $offset;
}
/**
* Load a Template by name.
*
* @throws Mustache_Exception_UnknownTemplateException If a template file is not found.
*
* @param string $name
*
* @return string Mustache Template source
*/
public function load($name)
{
$this->loadTemplates();
if (!array_key_exists($name, $this->templates)) {
throw new Mustache_Exception_UnknownTemplateException($name);
}
return $this->templates[$name];
}
/**
* Parse and load templates from the end of a source file.
*/
protected function loadTemplates()
{
if ($this->templates === null) {
$this->templates = array();
$data = file_get_contents($this->fileName, false, null, $this->offset);
foreach (preg_split("/^@@(?= [\w\d\.]+$)/m", $data, -1) as $chunk) {
if (trim($chunk)) {
list($name, $content) = explode("\n", $chunk, 2);
$this->templates[trim($name)] = trim($content);
}
}
}
}
}

View File

@ -1,32 +1,32 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Mustache Template mutable Loader interface.
*/
interface Mustache_Loader_MutableLoader
{
/**
* Set an associative array of Template sources for this loader.
*
* @param array $templates
*/
public function setTemplates(array $templates);
/**
* Set a Template source by name.
*
* @param string $name
* @param string $template Mustache Template source
*/
public function setTemplate($name, $template);
}
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Mustache Template mutable Loader interface.
*/
interface Mustache_Loader_MutableLoader
{
/**
* Set an associative array of Template sources for this loader.
*
* @param array $templates
*/
public function setTemplates(array $templates);
/**
* Set a Template source by name.
*
* @param string $name
* @param string $template Mustache Template source
*/
public function setTemplate($name, $template);
}

View File

@ -1,40 +1,40 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Mustache Template string Loader implementation.
*
* A StringLoader instance is essentially a noop. It simply passes the 'name' argument straight through:
*
* $loader = new StringLoader;
* $tpl = $loader->load('{{ foo }}'); // '{{ foo }}'
*
* This is the default Template Loader instance used by Mustache:
*
* $m = new Mustache;
* $tpl = $m->loadTemplate('{{ foo }}');
* echo $tpl->render(array('foo' => 'bar')); // "bar"
*/
class Mustache_Loader_StringLoader implements Mustache_Loader
{
/**
* Load a Template by source.
*
* @param string $name Mustache Template source
*
* @return string Mustache Template source
*/
public function load($name)
{
return $name;
}
}
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Mustache Template string Loader implementation.
*
* A StringLoader instance is essentially a noop. It simply passes the 'name' argument straight through:
*
* $loader = new StringLoader;
* $tpl = $loader->load('{{ foo }}'); // '{{ foo }}'
*
* This is the default Template Loader instance used by Mustache:
*
* $m = new Mustache;
* $tpl = $m->loadTemplate('{{ foo }}');
* echo $tpl->render(array('foo' => 'bar')); // "bar"
*/
class Mustache_Loader_StringLoader implements Mustache_Loader
{
/**
* Load a Template by source.
*
* @param string $name Mustache Template source
*
* @return string Mustache Template source
*/
public function load($name)
{
return $name;
}
}

View File

@ -1,135 +1,135 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Describes a Mustache logger instance
*
* This is identical to the Psr\Log\LoggerInterface.
*
* The message MUST be a string or object implementing __toString().
*
* The message MAY contain placeholders in the form: {foo} where foo
* will be replaced by the context data in key "foo".
*
* The context array can contain arbitrary data, the only assumption that
* can be made by implementors is that if an Exception instance is given
* to produce a stack trace, it MUST be in a key named "exception".
*
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
* for the full interface specification.
*/
interface Mustache_Logger
{
/**
* Psr\Log compatible log levels
*/
const EMERGENCY = 'emergency';
const ALERT = 'alert';
const CRITICAL = 'critical';
const ERROR = 'error';
const WARNING = 'warning';
const NOTICE = 'notice';
const INFO = 'info';
const DEBUG = 'debug';
/**
* System is unusable.
*
* @param string $message
* @param array $context
* @return null
*/
public function emergency($message, array $context = array());
/**
* Action must be taken immediately.
*
* Example: Entire website down, database unavailable, etc. This should
* trigger the SMS alerts and wake you up.
*
* @param string $message
* @param array $context
* @return null
*/
public function alert($message, array $context = array());
/**
* Critical conditions.
*
* Example: Application component unavailable, unexpected exception.
*
* @param string $message
* @param array $context
* @return null
*/
public function critical($message, array $context = array());
/**
* Runtime errors that do not require immediate action but should typically
* be logged and monitored.
*
* @param string $message
* @param array $context
* @return null
*/
public function error($message, array $context = array());
/**
* Exceptional occurrences that are not errors.
*
* Example: Use of deprecated APIs, poor use of an API, undesirable things
* that are not necessarily wrong.
*
* @param string $message
* @param array $context
* @return null
*/
public function warning($message, array $context = array());
/**
* Normal but significant events.
*
* @param string $message
* @param array $context
* @return null
*/
public function notice($message, array $context = array());
/**
* Interesting events.
*
* Example: User logs in, SQL logs.
*
* @param string $message
* @param array $context
* @return null
*/
public function info($message, array $context = array());
/**
* Detailed debug information.
*
* @param string $message
* @param array $context
* @return null
*/
public function debug($message, array $context = array());
/**
* Logs with an arbitrary level.
*
* @param mixed $level
* @param string $message
* @param array $context
* @return null
*/
public function log($level, $message, array $context = array());
}
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Describes a Mustache logger instance
*
* This is identical to the Psr\Log\LoggerInterface.
*
* The message MUST be a string or object implementing __toString().
*
* The message MAY contain placeholders in the form: {foo} where foo
* will be replaced by the context data in key "foo".
*
* The context array can contain arbitrary data, the only assumption that
* can be made by implementors is that if an Exception instance is given
* to produce a stack trace, it MUST be in a key named "exception".
*
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
* for the full interface specification.
*/
interface Mustache_Logger
{
/**
* Psr\Log compatible log levels
*/
const EMERGENCY = 'emergency';
const ALERT = 'alert';
const CRITICAL = 'critical';
const ERROR = 'error';
const WARNING = 'warning';
const NOTICE = 'notice';
const INFO = 'info';
const DEBUG = 'debug';
/**
* System is unusable.
*
* @param string $message
* @param array $context
* @return null
*/
public function emergency($message, array $context = array());
/**
* Action must be taken immediately.
*
* Example: Entire website down, database unavailable, etc. This should
* trigger the SMS alerts and wake you up.
*
* @param string $message
* @param array $context
* @return null
*/
public function alert($message, array $context = array());
/**
* Critical conditions.
*
* Example: Application component unavailable, unexpected exception.
*
* @param string $message
* @param array $context
* @return null
*/
public function critical($message, array $context = array());
/**
* Runtime errors that do not require immediate action but should typically
* be logged and monitored.
*
* @param string $message
* @param array $context
* @return null
*/
public function error($message, array $context = array());
/**
* Exceptional occurrences that are not errors.
*
* Example: Use of deprecated APIs, poor use of an API, undesirable things
* that are not necessarily wrong.
*
* @param string $message
* @param array $context
* @return null
*/
public function warning($message, array $context = array());
/**
* Normal but significant events.
*
* @param string $message
* @param array $context
* @return null
*/
public function notice($message, array $context = array());
/**
* Interesting events.
*
* Example: User logs in, SQL logs.
*
* @param string $message
* @param array $context
* @return null
*/
public function info($message, array $context = array());
/**
* Detailed debug information.
*
* @param string $message
* @param array $context
* @return null
*/
public function debug($message, array $context = array());
/**
* Logs with an arbitrary level.
*
* @param mixed $level
* @param string $message
* @param array $context
* @return null
*/
public function log($level, $message, array $context = array());
}

View File

@ -1,121 +1,121 @@
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* This is a simple Logger implementation that other Loggers can inherit from.
*
* This is identical to the Psr\Log\AbstractLogger.
*
* It simply delegates all log-level-specific methods to the `log` method to
* reduce boilerplate code that a simple Logger that does the same thing with
* messages regardless of the error level has to implement.
*/
abstract class Mustache_Logger_AbstractLogger implements Mustache_Logger
{
/**
* System is unusable.
*
* @param string $message
* @param array $context
*/
public function emergency($message, array $context = array())
{
$this->log(Mustache_Logger::EMERGENCY, $message, $context);
}
/**
* Action must be taken immediately.
*
* Example: Entire website down, database unavailable, etc. This should
* trigger the SMS alerts and wake you up.
*
* @param string $message
* @param array $context
*/
public function alert($message, array $context = array())
{
$this->log(Mustache_Logger::ALERT, $message, $context);
}
/**
* Critical conditions.
*
* Example: Application component unavailable, unexpected exception.
*
* @param string $message
* @param array $context
*/
public function critical($message, array $context = array())
{
$this->log(Mustache_Logger::CRITICAL, $message, $context);
}
/**
* Runtime errors that do not require immediate action but should typically
* be logged and monitored.
*
* @param string $message
* @param array $context
*/
public function error($message, array $context = array())
{
$this->log(Mustache_Logger::ERROR, $message, $context);
}
/**
* Exceptional occurrences that are not errors.
*
* Example: Use of deprecated APIs, poor use of an API, undesirable things
* that are not necessarily wrong.
*
* @param string $message
* @param array $context
*/
public function warning($message, array $context = array())
{
$this->log(Mustache_Logger::WARNING, $message, $context);
}
/**
* Normal but significant events.
*
* @param string $message
* @param array $context
*/
public function notice($message, array $context = array())
{
$this->log(Mustache_Logger::NOTICE, $message, $context);
}
/**
* Interesting events.
*
* Example: User logs in, SQL logs.
*
* @param string $message
* @param array $context
*/
public function info($message, array $context = array())
{
$this->log(Mustache_Logger::INFO, $message, $context);
}
/**
* Detailed debug information.
*
* @param string $message
* @param array $context
*/
public function debug($message, array $context = array())
{
$this->log(Mustache_Logger::DEBUG, $message, $context);
}
}
<?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* This is a simple Logger implementation that other Loggers can inherit from.
*
* This is identical to the Psr\Log\AbstractLogger.
*
* It simply delegates all log-level-specific methods to the `log` method to
* reduce boilerplate code that a simple Logger that does the same thing with
* messages regardless of the error level has to implement.
*/
abstract class Mustache_Logger_AbstractLogger implements Mustache_Logger
{
/**
* System is unusable.
*
* @param string $message
* @param array $context
*/
public function emergency($message, array $context = array())
{
$this->log(Mustache_Logger::EMERGENCY, $message, $context);
}
/**
* Action must be taken immediately.
*
* Example: Entire website down, database unavailable, etc. This should
* trigger the SMS alerts and wake you up.
*
* @param string $message
* @param array $context
*/
public function alert($message, array $context = array())
{
$this->log(Mustache_Logger::ALERT, $message, $context);
}
/**
* Critical conditions.
*
* Example: Application component unavailable, unexpected exception.
*
* @param string $message
* @param array $context
*/
public function critical($message, array $context = array())
{
$this->log(Mustache_Logger::CRITICAL, $message, $context);
}
/**
* Runtime errors that do not require immediate action but should typically
* be logged and monitored.
*
* @param string $message
* @param array $context
*/
public function error($message, array $context = array())
{
$this->log(Mustache_Logger::ERROR, $message, $context);
}
/**
* Exceptional occurrences that are not errors.
*
* Example: Use of deprecated APIs, poor use of an API, undesirable things
* that are not necessarily wrong.
*
* @param string $message
* @param array $context
*/
public function warning($message, array $context = array())
{
$this->log(Mustache_Logger::WARNING, $message, $context);
}
/**
* Normal but significant events.
*
* @param string $message
* @param array $context
*/
public function notice($message, array $context = array())
{
$this->log(Mustache_Logger::NOTICE, $message, $context);
}
/**
* Interesting events.
*
* Example: User logs in, SQL logs.
*
* @param string $message
* @param array $context
*/
public function info($message, array $context = array())
{
$this->log(Mustache_Logger::INFO, $message, $context);
}
/**
* Detailed debug information.
*
* @param string $message
* @param array $context
*/
public function debug($message, array $context = array())
{
$this->log(Mustache_Logger::DEBUG, $message, $context);
}
}

Some files were not shown because too many files have changed in this diff Show More