PluginProbe
GetResponse Forms by Optin Cat / 2.0.2
GetResponse Forms by Optin Cat v2.0.2
1.3.4 1.3.5 1.3.6 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 2.0.0 All 36 releases
← All changes | includes/eoi-widget.php +154 -154 1.5.82.0.2 View file →
@@ -1,154 +1,154 @@
1 -<?php
2 -
3 -class EasyOptInsWidgetHelper {
4 -
5 - var $settings;
6 -
7 - function __construct( $settings = array() ) {
8 -
9 - $this->settings = $settings;
10 -
11 - // Register widget
12 - add_action( 'widgets_init', array( $this, 'register_widget' ) );
13 - }
14 -
15 - function register_widget() {
16 -
17 - register_widget( 'EasyOptInsWidget' );
18 - }
19 -}
20 -
21 -class EasyOptInsWidget extends WP_Widget {
22 -
23 - function __construct() {
24 -
25 - $widget_ops = array(
26 - 'classname' => 'easy-opt-in-widget',
27 - 'description' => 'Displays your opt-in sign-up form.',
28 - );
29 -
30 - $control_ops = array(
31 - 'width' => 300,
32 - 'height' => 350,
33 - 'id_base' => 'easy-opt-in-widget',
34 - );
35 -
36 - parent::__construct(
37 - 'easy-opt-in-widget'
38 - , 'Optin Cat Sidebar Widget'
39 - , $widget_ops, $control_ops
40 - );
41 - }
42 -
43 - function widget( $args, $instance ) {
44 -
45 - global $fca_eoi_shortcodes;
46 - include_once plugin_dir_path( __FILE__ ) . 'eoi-shortcode.php';
47 -
48 - extract( $args );
49 -
50 - $form_id =
51 - preg_match( '/^([0-9])+$/sim', $instance[ 'eoi_form_id' ] )
52 - ? $instance['eoi_form_id']
53 - : 0
54 - ;
55 - $widget = $fca_eoi_shortcodes->shortcode_content( array( 'id' => $form_id ) );
56 -
57 - echo $before_widget . $widget . $after_widget;
58 - }
59 -
60 - function update( $new_instance, $old_instance ) {
61 -
62 - $instance = $old_instance;
63 - $instance[ 'eoi_form_id' ] = strip_tags( $new_instance[ 'eoi_form_id' ] );
64 -
65 - return $instance;
66 - }
67 -
68 - function form( $instance ) {
69 -
70 - global $post;
71 -
72 - $defaults = array( 'eoi_form_id' => '' );
73 - $instance = wp_parse_args( ( array ) $instance, $defaults );
74 - $options = array();
75 - $forms = get_posts( array(
76 - 'post_type' => 'easy-opt-ins',
77 - 'post_status' => 'publish',
78 - 'posts_per_page' => -1,
79 - ) );
80 -
81 - // Show error if there are no forms, then exit function
82 - if( empty ( $forms ) ) {
83 - K::wrap(
84 - sprintf(
85 - __( 'You have not created a form yet. <a href="%s" target="_blank">Create a form</a>.' )
86 - , admin_url( 'post-new.php?post_type=easy-opt-ins' )
87 - )
88 - , null
89 - , array( 'in' => 'p' )
90 - );
91 - return;
92 - }
93 -
94 - /**
95 - * Prepare forms dropdownlist
96 - *
97 - * 1. Form must have a thank you page and a list chosen
98 - * 2. Form must be a widget
99 - *
100 - */
101 - foreach ( $forms as $form ) {
102 - $fca_eoi = get_post_meta( $form->ID, 'fca_eoi', true );
103 - $provider = K::get_var( 'provider', $fca_eoi );
104 - $layout = K::get_var( 'layout', $fca_eoi );
105 - // Exlude forms not validating condition 1.
106 - if ( ! K::get_var( $provider . '_list_id', $fca_eoi ) || ! K::get_var( 'thank_you_page', $fca_eoi ) ) {
107 - continue;
108 - }
109 - // Exlude forms not validating condition 2.
110 - if( strpos( $layout , 'layout_' ) === 0 ) {
111 - /* We're good */
112 - } else {
113 - continue;
114 - }
115 -
116 - $title = $form->post_title
117 - ? $form->post_title
118 - : __( 'Untitled form' ) . ' (#' . $form->ID . ' )'
119 - ;
120 - $options[ $form->ID ] = $title;
121 - }
122 -
123 - // If no suitable form exists, show an indication and exit function
124 - if( ! $options ) {
125 - K::wrap(
126 - sprintf(
127 - __( 'Please make sure to connect <a href="%s" target="_blank">your form</a> to your email marketing provider and to select a thank you page.' )
128 - , admin_url( 'edit.php?post_type=easy-opt-ins' )
129 - )
130 - , null
131 - , array( 'in' => 'p' )
132 - );
133 - return;
134 - }
135 -
136 - // Add empty choice
137 - $options = array_reverse( $options, true );
138 - $options[ '' ] = 'Not set';
139 - $options = array_reverse( $options, true );
140 -
141 - // Show choices
142 - K::select( $this->get_field_name( 'eoi_form_id' )
143 - , array(
144 - 'id' => $this->get_field_id( 'eoi_form_id' ),
145 - )
146 - , array(
147 - 'options' => $options,
148 - 'default' => '',
149 - 'selected' => $instance['eoi_form_id'],
150 - 'format' => '<p><label for="' . $this->get_field_id( 'eoi_form_id' ) . '">' . __( 'Select form:' ) . '</label><p>:select</p>',
151 - )
152 - );
153 - }
154 -}
1 +<?php
2 +
3 +class EasyOptInsWidgetHelper {
4 +
5 + var $settings;
6 +
7 + function __construct( $settings = array() ) {
8 +
9 + $this->settings = $settings;
10 +
11 + // Register widget
12 + add_action( 'widgets_init', array( $this, 'register_widget' ) );
13 + }
14 +
15 + function register_widget() {
16 +
17 + register_widget( 'EasyOptInsWidget' );
18 + }
19 +}
20 +
21 +class EasyOptInsWidget extends WP_Widget {
22 +
23 + function __construct() {
24 +
25 + $widget_ops = array(
26 + 'classname' => 'easy-opt-in-widget',
27 + 'description' => 'Displays your opt-in sign-up form.',
28 + );
29 +
30 + $control_ops = array(
31 + 'width' => 300,
32 + 'height' => 350,
33 + 'id_base' => 'easy-opt-in-widget',
34 + );
35 +
36 + parent::__construct(
37 + 'easy-opt-in-widget'
38 + , 'Sidebar Optin Form (Optin Cat)'
39 + , $widget_ops, $control_ops
40 + );
41 + }
42 +
43 + function widget( $args, $instance ) {
44 +
45 + global $fca_eoi_shortcodes;
46 + include_once plugin_dir_path( __FILE__ ) . 'eoi-shortcode.php';
47 +
48 + extract( $args );
49 +
50 + $form_id =
51 + preg_match( '/^([0-9])+$/sim', $instance[ 'eoi_form_id' ] )
52 + ? $instance['eoi_form_id']
53 + : 0
54 + ;
55 + $widget = $fca_eoi_shortcodes->shortcode_content( array( 'id' => $form_id ) );
56 +
57 + echo $before_widget . $widget . $after_widget;
58 + }
59 +
60 + function update( $new_instance, $old_instance ) {
61 +
62 + $instance = $old_instance;
63 + $instance[ 'eoi_form_id' ] = strip_tags( $new_instance[ 'eoi_form_id' ] );
64 +
65 + return $instance;
66 + }
67 +
68 + function form( $instance ) {
69 +
70 + global $post;
71 +
72 + $defaults = array( 'eoi_form_id' => '' );
73 + $instance = wp_parse_args( ( array ) $instance, $defaults );
74 + $options = array();
75 + $forms = get_posts( array(
76 + 'post_type' => 'easy-opt-ins',
77 + 'post_status' => 'publish',
78 + 'posts_per_page' => -1,
79 + ) );
80 +
81 + // Show error if there are no forms, then exit function
82 + if( empty ( $forms ) ) {
83 + K::wrap(
84 + sprintf(
85 + __( 'You have not created a form yet. <a href="%s" target="_blank">Create a form</a>.' )
86 + , admin_url( 'post-new.php?post_type=easy-opt-ins' )
87 + )
88 + , null
89 + , array( 'in' => 'p' )
90 + );
91 + return;
92 + }
93 +
94 + /**
95 + * Prepare forms dropdownlist
96 + *
97 + * 1. Form must have a thank you page and a list chosen
98 + * 2. Form must be a widget
99 + *
100 + */
101 + foreach ( $forms as $form ) {
102 + $fca_eoi = get_post_meta( $form->ID, 'fca_eoi', true );
103 + $provider = K::get_var( 'provider', $fca_eoi );
104 + $layout = K::get_var( 'layout', $fca_eoi );
105 + // Exlude forms not validating condition 1.
106 + if ( ! K::get_var( $provider . '_list_id', $fca_eoi ) || ! K::get_var( 'thank_you_page', $fca_eoi ) ) {
107 + continue;
108 + }
109 + // Exlude forms not validating condition 2.
110 + if( strpos( $layout , 'layout_' ) === 0 ) {
111 + /* We're good */
112 + } else {
113 + continue;
114 + }
115 +
116 + $title = $form->post_title
117 + ? $form->post_title
118 + : __( 'Untitled form' ) . ' (#' . $form->ID . ' )'
119 + ;
120 + $options[ $form->ID ] = $title;
121 + }
122 +
123 + // If no suitable form exists, show an indication and exit function
124 + if( ! $options ) {
125 + K::wrap(
126 + sprintf(
127 + __( 'Please make sure to connect <a href="%s" target="_blank">your form</a> to your email marketing provider and to select a thank you page.' )
128 + , admin_url( 'edit.php?post_type=easy-opt-ins' )
129 + )
130 + , null
131 + , array( 'in' => 'p' )
132 + );
133 + return;
134 + }
135 +
136 + // Add empty choice
137 + $options = array_reverse( $options, true );
138 + $options[ '' ] = 'Not set';
139 + $options = array_reverse( $options, true );
140 +
141 + // Show choices
142 + K::select( $this->get_field_name( 'eoi_form_id' )
143 + , array(
144 + 'id' => $this->get_field_id( 'eoi_form_id' ),
145 + )
146 + , array(
147 + 'options' => $options,
148 + 'default' => '',
149 + 'selected' => $instance['eoi_form_id'],
150 + 'format' => '<p><label for="' . $this->get_field_id( 'eoi_form_id' ) . '">' . __( 'Select form:' ) . '</label><p>:select</p>',
151 + )
152 + );
153 + }
154 +}