Affiliate-Toolkit Shortcode'; $target = is_string( $args ) ? $args : 'content'; // Prepare args $args = wp_parse_args( $args, array( 'target' => $target, 'text' => esc_html__( 'Affiliate-Toolkit shortcodes', 'affiliate-toolkit-starter' ), 'class' => 'button', 'icon' => plugins_url( 'images/affiliate_toolkit_menu.png', ATKP_PLUGIN_FILE ), 'echo' => true, 'shortcode' => false ) ); // Prepare icon if ( $args['icon'] ) { $args['icon'] = ' '; } add_action( 'wp_footer', array( &$this, 'shortcode_popup' ) ); add_action( 'admin_footer', array( &$this, 'shortcode_popup' ) ); wp_register_style( 'magnific-popup', plugins_url( 'css/magnific-popup.css', ATKP_PLUGIN_FILE ), false, '0.9.9', 'all' ); wp_register_script( 'magnific-popup', plugins_url( 'js/magnific-popup.js', ATKP_PLUGIN_FILE ), array( 'jquery' ), '0.9.9', true ); wp_localize_script( 'magnific-popup', 'atkp_magnific_popup', array( 'close' => esc_html__( 'Close (Esc)', 'affiliate-toolkit-starter' ), 'loading' => esc_html__( 'Loading...', 'affiliate-toolkit-starter' ), 'prev' => esc_html__( 'Previous (Left arrow key)', 'affiliate-toolkit-starter' ), 'next' => esc_html__( 'Next (Right arrow key)', 'affiliate-toolkit-starter' ), /* translators: 1: current item number, 2: total items */ 'counter' => sprintf( esc_html__( '%1$s of %2$s', 'affiliate-toolkit-starter' ), '%curr%', '%total%' ), /* translators: 1: opening link tag, 2: closing link tag */ 'error' => sprintf( esc_html__( 'Failed to load this link. %1$sOpen link%2$s.', 'affiliate-toolkit-starter' ), '', '' ) ) ); wp_enqueue_style( 'magnific-popup' ); wp_enqueue_script( 'magnific-popup' ); // Print button $button = '' . wp_kses( $args['icon'], array( 'img' => array( 'src' => array() ) ) ) . esc_html( $args['text'] ) . ''; if ( $args['echo'] ) { echo '' . wp_kses( $args['icon'], array( 'img' => array( 'src' => array() ) ) ) . esc_html( $args['text'] ) . ''; } else { return $button; } } function shortcode_boxes() { $types = array( 'post', 'page' ); foreach ( $types as $type ) { //add_meta_box( // ATKP_SHORTCODE.'_detail_box', // esc_html__( 'Affiliate Toolkit Shortcodes', 'affiliate-toolkit-starter'), // array(&$this, 'template_detail_box_content'), // $type, // 'side', // 'default' //); add_meta_box( ATKP_PLUGIN_PREFIX . '_product_box', esc_html__( 'Affiliate Toolkit Product', 'affiliate-toolkit-starter' ), array( &$this, 'product_detail_box_content' ), $type, 'normal', 'default' ); } } function product_detail_box_content( $post ) { wp_nonce_field( plugin_basename( __FILE__ ), 'product_detail_box_content_nonce' ); ?>
array( 'post', 'page' ), // YOUR POST TYPE 'post_status' => array( 'publish', 'draft' ), // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query 'meta_query' => array( array( 'key' => ATKP_PLUGIN_PREFIX . '_product', 'value' => $productid, 'compare' => '=', 'type' => 'CHAR', ), ), ); // The Query $query = new WP_Query( $args ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); array_push( $postids, $query->post->ID ); } } wp_reset_postdata(); ATKPTools::set_post_setting( $productid, ATKP_PRODUCT_POSTTYPE . '_postid', $postids ); } } function template_detail_box_content( $post ) { ?>