| @@ -44,9 +44,9 @@ | ||
| 44 | 44 | public function button() { |
| 45 | 45 | global $post; |
| 46 | 46 | if (current_user_can( 'delete_pages' ) && $post->post_type != 'easy-opt-ins'){ |
| 47 | 47 | |
| 48 | - $button_title = __( 'Optin Cat' ); | |
| 48 | + $button_title = __( 'Add Optin Form' ); | |
| 49 | 49 | |
| 50 | 50 | if ( version_compare( $GLOBALS['wp_version'], '3.5', '<' ) ) { |
| 51 | 51 | echo '<a href="#TB_inline?width=640&inlineId=fca-eoi-shortcode-thickbox" class="thickbox" title="' . $button_title . '">' . $button_title . '</a>'; |
| 52 | 52 | } else { |
| @@ -108,19 +108,22 @@ | ||
| 108 | 108 | public function enqueue_assets() { |
| 109 | 109 | $protocol = is_ssl() ? 'https' : 'http'; |
| 110 | 110 | |
| 111 | 111 | wp_enqueue_script( 'jquery' ); |
| 112 | - wp_enqueue_style( 'fontawesome', $protocol . '://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.1.0/css/font-awesome.min.css' ); | |
| 112 | + wp_enqueue_style( 'fontawesome', $protocol . '://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.1.0/css/font-awesome.min.css', array(), FCA_EOI_VER ); | |
| 113 | 113 | |
| 114 | - wp_enqueue_script( 'tooltipster', FCA_EOI_PLUGIN_URL . '/assets/vendor/tooltipster/jquery.tooltipster.min.js' ); | |
| 115 | - wp_enqueue_style( 'tooltipster', FCA_EOI_PLUGIN_URL . '/assets/vendor/tooltipster/tooltipster.min.css' ); | |
| 114 | + wp_enqueue_script( 'fca_eoi_tooltipster_js', FCA_EOI_PLUGIN_URL . '/assets/vendor/tooltipster/tooltipster.bundle.min.js', array(), FCA_EOI_VER, true ); | |
| 115 | + wp_enqueue_style( 'fca_eoi_tooltipster_css', FCA_EOI_PLUGIN_URL . '/assets/vendor/tooltipster/tooltipster.bundle.min.css', array(), FCA_EOI_VER ); | |
| 116 | + wp_enqueue_style( 'fca_eoi_tooltipster_theme_css', FCA_EOI_PLUGIN_URL . '/assets/vendor/tooltipster/tooltipster-borderless.min.css', array(), FCA_EOI_VER ); | |
| 116 | 117 | |
| 117 | - wp_enqueue_script( 'fca_eoi_featherlight_js', FCA_EOI_PLUGIN_URL . '/assets/vendor/featherlight/release/featherlight.min.js' ); | |
| 118 | - wp_enqueue_style( 'fca_eoi_featherlight_css', FCA_EOI_PLUGIN_URL . '/assets/vendor/featherlight/release/featherlight.min.css' ); | |
| 118 | + wp_enqueue_script( 'fca_eoi_featherlight_js', FCA_EOI_PLUGIN_URL . '/assets/vendor/featherlight/release/featherlight.min.js', array(), FCA_EOI_VER, true ); | |
| 119 | + wp_enqueue_style( 'fca_eoi_featherlight_css', FCA_EOI_PLUGIN_URL . '/assets/vendor/featherlight/release/featherlight.min.css', array(), FCA_EOI_VER ); | |
| 120 | + | |
| 121 | + wp_enqueue_script( 'fca_eoi_jstz', FCA_EOI_PLUGIN_URL . '/assets/vendor/jstz/jstz.min.js', array(), FCA_EOI_VER, true ); | |
| 122 | + | |
| 123 | + wp_enqueue_style( 'fca_eoi', FCA_EOI_PLUGIN_URL . '/assets/style-new.min.css', array(), FCA_EOI_VER ); | |
| 124 | + wp_enqueue_script( 'fca_eoi_script_js', FCA_EOI_PLUGIN_URL . '/assets/script.min.js', array( 'fca_eoi_jstz', 'jquery', 'fca_eoi_tooltipster_js', 'fca_eoi_featherlight_js'), FCA_EOI_VER, true ); | |
| 119 | 125 | |
| 120 | - wp_enqueue_style( 'fca_eoi', FCA_EOI_PLUGIN_URL . '/assets/style-new.css' ); | |
| 121 | - wp_enqueue_script( 'fca_eoi_script_js', FCA_EOI_PLUGIN_URL . '/assets/script.js' ); | |
| 122 | - | |
| 123 | 126 | //PASS VARIABLES TO JAVASCRIPT |
| 124 | 127 | $data = array ( |
| 125 | 128 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 126 | 129 | 'nonce' => wp_create_nonce( 'fca_eoi_submit_form' ), |
| @@ -125,36 +128,43 @@ | ||
| 125 | 128 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 126 | 129 | 'nonce' => wp_create_nonce( 'fca_eoi_submit_form' ), |
| 127 | 130 | ); |
| 128 | 131 | |
| 129 | - wp_localize_script( 'fca_eoi_script_js', 'fca_eoi', $data ); | |
| 132 | + wp_localize_script( 'fca_eoi_script_js', 'fcaEoiScriptData', $data ); | |
| 130 | 133 | } |
| 131 | 134 | |
| 132 | 135 | public function shortcode_content( $atts ) { |
| 133 | - | |
| 134 | - $form_id = $atts['id']; | |
| 135 | - | |
| 136 | - /** | |
| 137 | - * Check that we have a valid post ID | |
| 138 | - */ | |
| 139 | - if( empty ( $form_id ) ) { | |
| 140 | - return 'Missing form ID'; | |
| 136 | + if ( empty ( $atts['id'] ) ) { | |
| 137 | + return 'Optin Cat: Invalid Form ID'; | |
| 138 | + } else { | |
| 139 | + $form_id = $atts['id']; | |
| 140 | + $post = get_post( $form_id ); | |
| 141 | 141 | } |
| 142 | - if( ! $post = get_post( $form_id ) ) { | |
| 143 | - return 'Wrong form ID'; | |
| 142 | + | |
| 143 | + if( !is_object( $post ) OR $post->post_status == 'trash' ) { | |
| 144 | + return 'Optin Cat: Missing Form Data. Is it in the trash?'; | |
| 144 | 145 | } |
| 146 | + | |
| 145 | 147 | $animation = get_post_meta( $form_id, 'fca_eoi_animation', true); |
| 146 | - if (!empty ($animation) ) { | |
| 147 | - wp_enqueue_style( 'fca_eoi_powerups_animate', FCA_EOI_PLUGIN_URL . '/assets/vendor/animate/animate.css' ); | |
| 148 | + if (!empty( $animation ) ) { | |
| 149 | + wp_enqueue_style( 'fca_eoi_powerups_animate', FCA_EOI_PLUGIN_URL . '/assets/vendor/animate/animate.min.css', array(), FCA_EOI_VER ); | |
| 148 | 150 | } |
| 151 | + | |
| 149 | 152 | $this->enqueue_assets(); |
| 150 | 153 | $head = get_post_meta( $form_id, 'fca_eoi_head', true ); |
| 151 | 154 | |
| 152 | 155 | $layout_id = get_post_meta ( $form_id, 'fca_eoi_layout', true ); |
| 153 | - $layout = new EasyOptInsLayout( $layout_id ); | |
| 156 | + $layout = new EasyOptInsLayout( $layout_id ); | |
| 154 | 157 | |
| 155 | - if ( $layout->layout_type != 'lightbox' ) { | |
| 156 | - $head .= '<script>' . EasyOptInsActivity::get_instance()->get_tracking_code( $form_id ) . '</script>'; | |
| 158 | + if ( $layout->layout_type !== 'lightbox' && $layout->layout_type !== 'banner' && $layout->layout_type !== 'overlay' ) { | |
| 159 | + | |
| 160 | + require_once FCA_EOI_PLUGIN_DIR . 'includes/classes/RobotDetector/RobotDetector.php'; | |
| 161 | + $robot_detector = new RobotDetector(); | |
| 162 | + | |
| 163 | + if ( get_post( $form_id ) && !is_user_logged_in() && !$robot_detector->is_robot() ) { | |
| 164 | + EasyOptInsActivity::get_instance()->add_impression( $form_id ); | |
| 165 | + } | |
| 166 | + | |
| 157 | 167 | } |
| 158 | 168 | |
| 159 | 169 | return $head; |
| 160 | 170 | } |