settings = $settings; // Add shortcode add_shortcode( $this->settings[ 'shortcode' ], array( $this, 'shortcode_content' ) ); // Add shortcode aliases foreach ( $settings[ 'shortcode_aliases' ] as $shortcode) { add_shortcode( $shortcode, array( $this, 'shortcode_content' ) ); } // Add shortcode generator button if ( FCA_EOI_EDITION != 'email_popup' && in_array( $pagenow, array( 'post.php', 'page.php', 'post-new.php', 'post-edit.php' ) ) && $typenow != 'download' ) { add_action( 'admin_head', array( $this, 'button_head' ) ); add_action( 'media_buttons', array( $this, 'button' ), 1000 ); add_action( 'admin_footer', array( $this, 'button_footer' ) ); } } public function button_head() { ?> post_type != 'easy-opt-ins'){ $button_title = __( 'Add Optin Form' ); if ( version_compare( $GLOBALS['wp_version'], '3.5', '<' ) ) { echo '' . $button_title . ''; } else { $img = ''; echo '' . $img . $button_title . ''; } } } public function button_footer() { $options = array(); foreach ( get_posts( array( 'post_type' => 'easy-opt-ins', 'post_status' => 'publish', 'posts_per_page' => -1 ) ) as $post ) { $form_id = $post->ID; $layout = get_post_meta( $form_id, 'fca_eoi_layout', true ); if ( ! empty( $layout ) && strpos( $layout, 'postbox_' ) === 0 ) { $options[ $form_id ] = empty( $post->post_title ) ? '(no title)' : $post->post_title; } } ?> admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'fca_eoi_submit_form' ), ); wp_localize_script( 'fca_eoi_script_js', 'fcaEoiScriptData', $data ); } public function shortcode_content( $atts ) { if ( empty ( $atts['id'] ) ) { return 'Optin Cat: Invalid Form ID'; } else { $form_id = $atts['id']; $post = get_post( $form_id ); } if( !is_object( $post ) OR $post->post_status == 'trash' ) { return 'Optin Cat: Missing Form Data. Is it in the trash?'; } $animation = get_post_meta( $form_id, 'fca_eoi_animation', true); if (!empty( $animation ) ) { wp_enqueue_style( 'fca_eoi_powerups_animate', FCA_EOI_PLUGIN_URL . '/assets/vendor/animate/animate.min.css', array(), FCA_EOI_VER ); } $this->enqueue_assets(); $head = get_post_meta( $form_id, 'fca_eoi_head', true ); $layout_id = get_post_meta ( $form_id, 'fca_eoi_layout', true ); $layout = new EasyOptInsLayout( $layout_id ); if ( $layout->layout_type !== 'lightbox' && $layout->layout_type !== 'banner' && $layout->layout_type !== 'overlay' ) { require_once FCA_EOI_PLUGIN_DIR . 'includes/classes/RobotDetector/RobotDetector.php'; $robot_detector = new RobotDetector(); if ( get_post( $form_id ) && !is_user_logged_in() && !$robot_detector->is_robot() ) { EasyOptInsActivity::get_instance()->add_impression( $form_id ); } } return $head; } }