Skip to content

Commit

Permalink
fix: container padding option
Browse files Browse the repository at this point in the history
  • Loading branch information
shin committed Oct 31, 2017
1 parent 423b987 commit 77b16a4
Show file tree
Hide file tree
Showing 11 changed files with 201 additions and 35 deletions.
2 changes: 2 additions & 0 deletions assets/css/cherry-popups-styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,8 @@
font-size: 30px; }
.cherry-popup-wrapper .cherry-popup-close-button:hover {
color: #e54343; }
.cherry-popup-wrapper .cherry-popup-close-label {
cursor: pointer; }
.cherry-popup-wrapper .cherry-popup-check {
display: -webkit-box;
display: -webkit-flex;
Expand Down
11 changes: 11 additions & 0 deletions assets/js/cherry-popups-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,17 @@
}, 300 );
} );

$this.on( 'click', '.cherry-popup-close-label', function( event ) {
var overlay = event.currentTarget;

$this.toggleClass( 'hide-animation show-animation' );

clearTimeout( timeout );
timeout = setTimeout( function() {
hidePopup();
}, 300 );
} );

$( document ).on( 'keyup', function( event ) {

if ( ! $this.hasClass( 'show-animation' ) ) {
Expand Down
4 changes: 4 additions & 0 deletions assets/sass/cherry-popups-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
}
}

.cherry-popup-close-label {
cursor: pointer;
}

.cherry-popup-check {
display: flex;
height: 20px;
Expand Down
30 changes: 27 additions & 3 deletions cherry-popups-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Cherry PopUps
* Plugin URI: https://jetimpex.com/wordpress/
* Description: A plugin for WordPress.
* Version: 1.1.5
* Version: 1.1.6
* Author: Jetimpex
* Author URI: https://jetimpex.com/wordpress/
* Text Domain: cherry-popups
Expand All @@ -13,7 +13,7 @@
*
* @package Cherry_Popups
* @author Cherry Team
* @version 1.1.5
* @version 1.1.6
* @license GPL-3.0+
* @copyright 2002-2016, Cherry Team
*/
Expand Down Expand Up @@ -63,6 +63,15 @@ class Cherry_Popups {
*/
public $dynamic_css = null;

/**
* Holder for base plugin path
*
* @since 1.0.0
* @access private
* @var string
*/
private $plugin_path = null;

/**
* Default options
*
Expand Down Expand Up @@ -142,7 +151,7 @@ public function constants() {
*
* @since 1.0.0
*/
define( 'CHERRY_POPUPS_VERSION', '1.1.5' );
define( 'CHERRY_POPUPS_VERSION', '1.1.6' );

/**
* Set constant name for the post type name.
Expand Down Expand Up @@ -403,6 +412,21 @@ public function get_option( $option_name, $option_default = false ) {
return $option_default;
}

/**
* Returns path to file or dir inside plugin folder
*
* @param string $path Path inside plugin dir.
* @return string
*/
public function plugin_path( $path = null ) {

if ( ! $this->plugin_path ) {
$this->plugin_path = trailingslashit( plugin_dir_path( __FILE__ ) );
}

return $this->plugin_path . $path;
}

/**
* On plugin activation.
*
Expand Down
2 changes: 0 additions & 2 deletions includes/admin/class-cherry-popups-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ public function cherry_restore_options() {
cherry_popups()->save_options( CHERRY_OPTIONS_NAME, $default_options );
}



/**
* Enqueue admin stylesheets.
*
Expand Down
24 changes: 24 additions & 0 deletions includes/admin/class-cherry-popups-meta-boxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public function init() {
'options' => array(
'default' => esc_html__( 'Default(Content + Subscribe form)', 'cherry-popups' ),
'simple' => esc_html__( 'Simple(Title + Content)', 'cherry-popups' ),
'content' => esc_html__( 'Content Only', 'cherry-popups' ),
'login' => esc_html__( 'Login Form', 'cherry-popups' ),
'signup' => esc_html__( 'New User Register Form', 'cherry-popups' ),
'subscribe' => esc_html__( 'Subscribe Form', 'cherry-popups' ),
Expand Down Expand Up @@ -230,6 +231,7 @@ public function init() {
),
),
),

$prefix . 'overlay-color' => array(
'type' => 'colorpicker',
'parent' => 'overlay_tab',
Expand Down Expand Up @@ -363,6 +365,28 @@ public function init() {
'value' => 3,
),

$prefix . 'content-position' => array(
'type' => 'radio',
'parent' => 'style_tab',
'title' => esc_html__( 'Content Position', 'cherry-popups' ),
'value' => 'center',
'display-input' => true,
'options' => array(
'flex-start' => array(
'label' => esc_html__( 'Top', 'cherry-popups' ),
),
'center' => array(
'label' => esc_html__( 'Center', 'cherry-popups' ),
),
'flex-end' => array(
'label' => esc_html__( 'Bottom', 'cherry-popups' ),
),
'stretch' => array(
'label' => esc_html__( 'Stretch', 'cherry-popups' ),
),
),
),

$prefix . 'popup-open-appear-event' => array(
'type' => 'radio',
'parent' => 'open_page_tab',
Expand Down
15 changes: 14 additions & 1 deletion includes/public/class-popups-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ public function __construct( $options = array() ) {
'base-style' => $this->get_popup_meta_field( 'cherry-popup-base-style', 'light' ),
'width' => $this->get_popup_meta_field( 'cherry-popup-width', 600 ),
'height' => $this->get_popup_meta_field( 'cherry-popup-height', 400 ),
'padding' => $this->get_popup_meta_field( 'cherry-popup-padding', 20 ),
'padding' => $this->get_popup_meta_field( 'cherry-popup-padding', 0 ),
'container-bg-type' => $this->get_popup_meta_field( 'cherry-container-bg-type', 'fill-color' ),
'container-color' => $this->get_popup_meta_field( 'cherry-container-color', '#fff' ),
'container-opacity' => $this->get_popup_meta_field( 'cherry-container-opacity', 100 ),
'container-image' => $this->get_popup_meta_field( 'cherry-container-image', '' ),
'border-radius' => $this->get_popup_meta_field( 'cherry-border-radius', 3 ),
'content-position' => $this->get_popup_meta_field( 'cherry-content-position', 'center' ),
'show-once' => $this->get_popup_meta_field( 'cherry-show-once', 'false' ),
'overlay-type' => $this->get_popup_meta_field( 'cherry-overlay-type', 'fill-color' ),
'overlay-color' => $this->get_popup_meta_field( 'cherry-overlay-color', '#000' ),
Expand Down Expand Up @@ -124,6 +125,10 @@ public function render_popup() {
$template_name = 'default-simple-popup.tmpl';
break;

case 'content':
$template_name = 'default-content-only-popup.tmpl';
break;

case 'login':
$template_name = 'default-login-popup.tmpl';
break;
Expand Down Expand Up @@ -235,6 +240,13 @@ public function generate_dynamic_styles() {
)
);

cherry_popups()->dynamic_css->add_style(
sprintf( '.cherry-popup-%1$s .cherry-popup-container__inner', $this->options['id'] ),
array(
'justify-content' => $this->popup_settings['content-position'],
)
);

// Overlay styles
switch ( $this->popup_settings['overlay-type'] ) {
case 'fill-color':
Expand Down Expand Up @@ -298,6 +310,7 @@ function setup_template_data( $atts ) {
'subscribeform' => array( $callbacks, 'get_subscribe_form' ),
'loginform' => array( $callbacks, 'get_login_form' ),
'registerform' => array( $callbacks, 'get_register_form' ),
'closelabel' => array( $callbacks, 'get_close_label' ),
);

/**
Expand Down
45 changes: 42 additions & 3 deletions includes/public/class-popups-registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,27 @@ public function __construct() {
add_action( 'load-post.php', array( $this, 'add_post_formats_support' ) );
add_action( 'load-post-new.php', array( $this, 'add_post_formats_support' ) );

add_filter( 'option_elementor_cpt_support', array( $this, 'set_option_support' ) );
add_filter( 'default_option_elementor_cpt_support', array( $this, 'set_option_support' ) );

add_action( 'template_include', array( $this, 'set_post_type_template' ), 9999 );

// Removes rewrite rules and then recreate rewrite rules.
// add_action( 'init', array( $this, 'rewrite_rules' ) );
}

/**
* Add elementor support for mega menu items.
*/
public function set_option_support( $value ) {

if ( empty( $value ) ) {
$value = array();
}

return array_merge( $value, array( CHERRY_POPUPS_NAME ) );
}

/**
* Register the custom post type.
*
Expand All @@ -51,6 +68,7 @@ public static function register() {

$labels = array(
'name' => __( 'PopUps', 'cherry-popups' ),
'menu_name' => __( 'PopUps', 'cherry-popups' ),
'singular_name' => __( 'Popups list', 'cherry-popups' ),
'add_new' => __( 'Add Popup', 'cherry-popups' ),
'add_new_item' => __( 'Add Popup Item', 'cherry-popups' ),
Expand All @@ -73,7 +91,8 @@ public static function register() {
'labels' => $labels,
'supports' => $supports,
'exclude_from_search' => false,
'publicly_queryable' => false,
'publicly_queryable' => true,
'public' => true,
'show_in_nav_menus' => false,
'show_ui' => true,
'show_in_menu' => true,
Expand All @@ -82,8 +101,9 @@ public static function register() {
'menu_position' => null,
'menu_icon' => ( version_compare( $GLOBALS['wp_version'], '3.8', '>=' ) ) ? CHERRY_POPUPS_URI . 'assets/img/svg/cherry-popup-icon.svg' : '',
'can_export' => true,
'has_archive' => true,
'taxonomies' => array( 'post_format' ),
'has_archive' => false,
'rewrite' => true,
'taxonomies' => array(),
);

$args = apply_filters( 'cherry_popups_post_type_args', $args );
Expand Down Expand Up @@ -114,6 +134,25 @@ public function rewrite_rules() {
flush_rewrite_rules();
}

/**
* Set blank template for editor
*/
public function set_post_type_template( $template ) {
$found = false;

if ( is_singular( CHERRY_POPUPS_NAME ) ) {
$found = true;
$template = cherry_popups()->plugin_path( 'templates/blank.php' );
}

if ( $found ) {
do_action( 'cherry-popups/template-include/found' );
}

return $template;

}

/**
* Returns the instance.
*
Expand Down
69 changes: 43 additions & 26 deletions includes/public/class-popups-template-callbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,15 @@ public function get_content( $attr = array() ) {

$attr = wp_parse_args( $attr, $default_attr );

ob_start();
?><div class="cherry-popup-content"><?php
global $post;

$content = $post_data->post_content;
$content = str_replace( ']]>', ']]&gt;', $content );
echo do_shortcode( $content );
?></div><?php
$content = ob_get_contents();
$post = get_post( $this->popup_id );

ob_end_clean();
setup_postdata( $post );
ob_start();
the_content();
$content = sprintf( '<div class="cherry-popup-content">%s</div>', ob_get_clean() );
wp_reset_postdata();

return $content;
}
Expand All @@ -153,8 +152,8 @@ public function get_content( $attr = array() ) {
*/
public function get_subscribe_form( $attr = array() ) {
$default_attr = array(
'submit_text' => esc_html__( 'Subscribe', 'cherry-projects' ),
'placeholder_text' => esc_html__( 'Your email', 'cherry-projects' ),
'submit_text' => esc_html__( 'Subscribe', 'cherry-popups' ),
'placeholder_text' => esc_html__( 'Your email', 'cherry-popups' ),
);

$attr = wp_parse_args( $attr, $default_attr );
Expand All @@ -179,15 +178,15 @@ public function get_subscribe_form( $attr = array() ) {
*/
public function get_login_form( $attr = array() ) {
$default_attr = apply_filters( 'cherry_popup_login_form_defaults_attr', array(
'submit_text' => esc_html__( 'Log in', 'cherry-projects' ),
'user_placeholder' => esc_html__( 'Login', 'cherry-projects' ),
'password_placeholder' => esc_html__( 'Password', 'cherry-projects' ),
'sign_up_message' => esc_html__( 'Don\'t have an account? Click here to', 'cherry-projects' ),
'sign_up_link_text' => esc_html__( 'Sign up', 'cherry-projects' ),
'sign_up_link' => esc_html__( '#', 'cherry-projects' ),
'remember_message' => esc_html__( 'Remember me', 'cherry-projects' ),
'use_mail' => esc_html__( 'or use your login data', 'cherry-projects' ),
'already_login_text' => esc_html__( 'You are currently logged in', 'cherry-projects' ),
'submit_text' => esc_html__( 'Log in', 'cherry-popups' ),
'user_placeholder' => esc_html__( 'Login', 'cherry-popups' ),
'password_placeholder' => esc_html__( 'Password', 'cherry-popups' ),
'sign_up_message' => esc_html__( 'Don\'t have an account? Click here to', 'cherry-popups' ),
'sign_up_link_text' => esc_html__( 'Sign up', 'cherry-popups' ),
'sign_up_link' => esc_html__( '#', 'cherry-popups' ),
'remember_message' => esc_html__( 'Remember me', 'cherry-popups' ),
'use_mail' => esc_html__( 'or use your login data', 'cherry-popups' ),
'already_login_text' => esc_html__( 'You are currently logged in', 'cherry-popups' ),
) );

$attr = wp_parse_args( $attr, $default_attr );
Expand Down Expand Up @@ -242,13 +241,13 @@ public function get_login_form( $attr = array() ) {
*/
public function get_register_form( $attr = array() ) {
$default_attr = apply_filters( 'cherry_popup_register_form_defaults_attr', array(
'submit_text' => esc_html__( 'Sign up', 'cherry-projects' ),
'login_placeholder' => esc_html__( 'Login', 'cherry-projects' ),
'mail_placeholder' => esc_html__( 'Email', 'cherry-projects' ),
'have_account' => esc_html__( 'Already have an account?', 'cherry-projects' ),
'login_link_text' => esc_html__( 'Log in', 'cherry-projects' ),
'login_link' => esc_html__( '#', 'cherry-projects' ),
'new_user_data' => esc_html__( 'or enter your registration credentials', 'cherry-projects' ),
'submit_text' => esc_html__( 'Sign up', 'cherry-popups' ),
'login_placeholder' => esc_html__( 'Login', 'cherry-popups' ),
'mail_placeholder' => esc_html__( 'Email', 'cherry-popups' ),
'have_account' => esc_html__( 'Already have an account?', 'cherry-popups' ),
'login_link_text' => esc_html__( 'Log in', 'cherry-popups' ),
'login_link' => esc_html__( '#', 'cherry-popups' ),
'new_user_data' => esc_html__( 'or enter your registration credentials', 'cherry-popups' ),
) );

$attr = wp_parse_args( $attr, $default_attr );
Expand Down Expand Up @@ -283,4 +282,22 @@ public function get_register_form( $attr = array() ) {
return $html;
}

/**
* Get register form.
*
* @since 1.0.0
*/
public function get_close_label( $attr = array() ) {

$default_attr = apply_filters( 'cherry_popup_close_label_defaults_attr', array(
'label_text' => esc_html__( 'Close Popup', 'cherry-popups' ),
) );

$attr = wp_parse_args( $attr, $default_attr );

$html = '<span class="cherry-popup-close-label">' . $attr['label_text'] . '</span>';

return $html;
}

}
Loading

0 comments on commit 77b16a4

Please sign in to comment.