Plugin Directory

Changeset 1477390


Ignore:
Timestamp:
08/17/2016 11:41:16 PM (10 years ago)
Author:
Vincent Stark
Message:

[VID-46] Email and pro activation notices

Location:
video-capture/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • video-capture/trunk/settings.php

    r1477386 r1477390  
    3232
    3333            // Register actions.
    34             add_action( 'admin_init', array( &$this, 'hide_registration_notice' ) );
     34            add_action( 'admin_init', array( &$this, 'hide_email_notification_notice' ) );
    3535            add_action( 'admin_init', array( &$this, 'hide_pro_activation_notice' ) );
    3636            add_action( 'admin_init', array( &$this, 'admin_init' ) );
     
    4646        public function validate_email( $email ) {
    4747            if ( ! is_email( $email ) && '' !== $email ) {
    48                 add_settings_error( 'vidrack_pro_account_email', 'video-capture-invalid-email', 'Please enter a correct email' );
     48                add_settings_error( 'vidrack_notifications_email', 'video-capture-invalid-email', 'Please enter a correct email' );
    4949            } else {
     50                // Register user.
     51                $this->video_capture_email->register_user( $email );
    5052                return $email;
    5153            }
     
    5860        public function notifications_email_notice() {
    5961            printf(
    60                 '<div class="updated"><p>%1$s <input type="button" class="button" value="%3$s" onclick="document.location.href=\'%2$s\';" /></div>',
    61                 'Your Vidrack Pro subscription successfully activated!',
     62                '<div class="update-nag"><p>%1$s <input type="button" class="button" value="%3$s" onclick="document.location.href=\'%2$s\';" /></div>',
     63                'Please enter your email to get notifications about newly uploaded videos',
    6264                esc_url( add_query_arg( 'wp-video-capture-nag', wp_create_nonce( 'wp-video-capture-nag' ) ) ),
    6365                'Dismiss'
     
    6668
    6769        /**
    68          * Hide registration notice upon click.
    69          */
    70         public function hide_registration_notice() {
     70         * Hide email notification upon click.
     71         */
     72        public function hide_email_notification_notice() {
    7173            if ( ! isset( $_GET['wp-video-capture-nag'] ) ) {  // Input var "wp-video-capture-nag" is not set.
    7274                return;
     
    7779
    7880            // Update user meta to indicate dismissed notice.
    79             update_user_meta( get_current_user_id(), '_wp-video-capture_hide_registration_notice', true );
     81            update_user_meta( get_current_user_id(), '_wp-video-capture_hide_email_notification_notice', true );
    8082        }
    8183
     
    108110
    109111        /**
     112         * Send email upon registration.
     113         */
     114        public function pro_activation_success_notice() {
     115            printf(
     116                '<div class="updated"><p>%1$s</div>',
     117                'Vidrack Pro version successfully activated!'
     118            );
     119        }
     120
     121        /**
    110122         * Main pro settings init function.
    111123         */
     
    117129                && 'edit.php' === $pagenow
    118130                && 'wp_video_capture_settings' === $_GET['page'] // Input var "page" is set.
    119                 && ! get_user_meta( get_current_user_id(), '_wp-video-capture_hide_registration_notice', true ) ) {
    120 
    121                 // Register user.
    122                 $this->video_capture_email->register_user( get_option( 'vidrack_pro_account_email' ) );
    123                 add_action( 'admin_notices', array( &$this, 'notifications_email_notice' ) );
    124                 update_user_meta( get_current_user_id(), '_wp-video-capture_hide_registration_notice', true );
     131                && ! get_user_meta( get_current_user_id(), '_wp-video-capture_hide_pro_activation_success_notice', true ) ) {
     132
     133                add_action( 'admin_notices', array( &$this, 'pro_activation_success_notice' ) );
     134
     135                update_user_meta( get_current_user_id(), '_wp-video-capture_hide_pro_activation_success_notice', true );
    125136            }
    126137
     
    269280
    270281            // Display notice about Pro activation.
    271             if ( ! $this->pro_account && ('vidrack_video' === $_GET['post_type'] || 'wp_video_capture_settings' === $_GET['page'] ) // Input var "page" is set.
    272                 && ! get_user_meta( get_current_user_id(), '_wp-video-capture_hide_pro_activation_notice', true ) ) {
    273                 add_action( 'admin_notices', array( &$this, 'pro_activation_notice' ) );
    274             }
     282            if ( 'vidrack_video' === $_GET['post_type'] || 'wp_video_capture_settings' === $_GET['page'] ) { // Input var "page" is set.
     283                if( ! $this->pro_account && ! get_user_meta( get_current_user_id(), '_wp-video-capture_hide_pro_activation_notice', true ) ) {
     284                    add_action( 'admin_notices', array( &$this, 'pro_activation_notice' ) );
     285                }
     286                if(  ! get_option( 'vidrack_notifications_email' ) && ! get_user_meta( get_current_user_id(), '_wp-video-capture_hide_email_notification_notice', true ) ) {
     287                    add_action( 'admin_notices', array( &$this, 'notifications_email_notice' ) );
     288                }
     289            }
     290
     291            // Register and validate Mail options.
     292            register_setting( 'wp_video_capture-group', 'vidrack_notifications_email', array( &$this, 'validate_email' ) );
    275293
    276294            // Register Pro account options.
    277295            register_setting( 'wp_video_capture-group', 'vidrack_pro_account_key' );
    278             register_setting( 'wp_video_capture-group', 'vidrack_pro_account_email', array( &$this, 'validate_email' ) );
     296            register_setting( 'wp_video_capture-group', 'vidrack_pro_account_email' );
    279297
    280298            register_setting( 'wp_video_capture-group', 'vidrack_js_callback' );
     
    291309            );
    292310
     311            add_settings_section(
     312                'wp_video_capture-section-email',
     313                'Notifications Email Settings',
     314                array( &$this, 'settings_section_wp_video_capture_email' ),
     315                'wp_video_capture-email'
     316            );
     317
    293318            // Add your settings section.
    294319            add_settings_section(
     
    356381                array(
    357382                    'field' => 'vidrack_window_modal',
     383                )
     384            );
     385
     386            // Add email setting field.
     387            add_settings_field(
     388                'wp_video_capture-notifications_email',
     389                'Notifications email',
     390                array( &$this, 'settings_field_input_text' ),
     391                'wp_video_capture-email',
     392                'wp_video_capture-section-email',
     393                array(
     394                    'field' => 'vidrack_notifications_email',
    358395                )
    359396            );
  • video-capture/trunk/templates/settings.php

    r1477388 r1477390  
    1818        <?php do_settings_sections( 'wp_video_capture_pro' ); ?>
    1919        <?php do_settings_sections( 'wp_video_capture' ); ?>
     20        <?php do_settings_sections( 'wp_video_capture-email' ); ?>
    2021        <?php do_settings_sections( 'wp_video_capture-youtube' ); ?>
    2122        <?php do_settings_sections( 'wp_video_capture-collect' ); ?>
  • video-capture/trunk/wp-video-capture.php

    r1477389 r1477390  
    130130                            add_action( 'admin_notices', array( $this, 'notice_validation_pro_account' ) );
    131131                        }
    132                         add_action( 'admin_init', array( $this, 'hide_registration_notice' ) );
     132                        add_action( 'admin_init', array( $this, 'hide_pro_activation_success_notice' ) );
    133133                        return false;
    134134                    }
     
    157157         */
    158158        function hide_registration_notice() {
    159             update_user_meta( get_current_user_id(), '_wp-video-capture_hide_registration_notice', false );
     159            update_user_meta( get_current_user_id(), '_wp-video-capture_hide_pro_activation_success_notice', false );
    160160        }
    161161
     
    241241            add_option( 'vidrack_collect_language', 'no' );
    242242            add_option( 'vidrack_version', self::$vidrack_version );
    243 
    244             // Add user config.
    245             add_user_meta( get_current_user_id(), '_wp-video-capture_hide_registration_notice', false, true );
    246243        }
    247244
     
    640637            } else {
    641638                // Send email notification.
    642                 if ( $this->pro_account && $to = get_option( 'vidrack_pro_account_email' ) ) {
     639                if ( $to = get_option( 'vidrack_notifications_email' ) ) {
    643640                    $this->video_capture_email->send_new_video_email( $to,  sanitize_text_field( wp_unslash( $_POST['filename'] ) ) ); // Input var "filename" is set.
    644641                }
Note: See TracChangeset for help on using the changeset viewer.