shortcode_buttons( $args ); //TODO: implement cache ?> Affiliate-Toolkit Shortcode'; $post = get_post(); if ( $post ) { $typenow = $post->post_type; } else { $typenow = ''; } $sel_post_types = get_option( ATKP_PLUGIN_PREFIX . '_custom_posttypes', null ); $page = ATKPTools::get_get_parameter( 'page', 'string' ); $allowed_pages = array(); array_push( $allowed_pages, 'ATKP_affiliate_toolkit-plugin' ); if ( $sel_post_types == null || ! is_array( $sel_post_types ) ) { $sel_post_types = array(); } array_push( $sel_post_types, 'post' ); array_push( $sel_post_types, 'page' ); array_push( $sel_post_types, ATKP_PRODUCT_POSTTYPE ); if ( ! in_array( $typenow, $sel_post_types ) && ! in_array( $page, $allowed_pages ) ) { return; } $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' => esc_url(plugins_url( 'images/affiliate_toolkit_menu.png', ATKP_PLUGIN_FILE )), 'echo' => true, 'shortcode' => false ) ); // Prepare icon if ( $args['icon'] ) { $args['icon'] = ' '; } $additional_shortcode_button = get_option( ATKP_PLUGIN_PREFIX . '_additional_shortcode_button', 0 ) ? '' : 'display:none;'; wp_register_style( 'magnific-popup', esc_url(plugins_url( 'css/magnific-popup.css', ATKP_PLUGIN_FILE )), false, '0.9.9', 'all' ); wp_register_script( 'magnific-popup', esc_url(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' ); $types = apply_filters( 'atkp_mainproduct_posttypes', $types ); foreach ( $types as $type ) { add_meta_box( ATKP_PLUGIN_PREFIX . '_product_box', esc_html__( 'affiliate-toolkit', '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' ); ?>
update_main_data( $post_id, '_product', ATKP_PRODUCT_POSTTYPE, $types ); $this->update_main_data( $post_id, '_list', ATKP_LIST_POSTTYPE, $types ); } function update_main_data( $post_id, $field = '_product', $posttype = ATKP_PRODUCT_POSTTYPE, $posttypes = [ 'post', 'page' ] ) { $productid = ATKPTools::get_post_parameter( ATKP_PLUGIN_PREFIX . $field, 'int' ); $oldproductid = ATKPTools::get_post_setting( $post_id, ATKP_PLUGIN_PREFIX . $field ); //lade das produkt und schau ob es vorhanden ist $prd = get_post( $productid ); if ( ! isset( $prd ) || $prd == null ) { //wenn es nicht existiert, verknüpfung löschen ATKPTools::set_post_setting( $post_id, ATKP_PLUGIN_PREFIX . $field, null ); } else { //wenn das Produkt exisitert, dann lege in diesem Beitrag ein benutzerdefiniertes Feld an ATKPTools::set_post_setting( $post_id, ATKP_PLUGIN_PREFIX . $field, $productid ); } $changedids = array(); if ( $oldproductid != $productid ) { if ( $oldproductid != null && $oldproductid != 0 ) { array_push( $changedids, $oldproductid ); } if ( $productid != null && $productid != 0 ) { array_push( $changedids, $productid ); } } foreach ( $changedids as $prdid ) { //im produkt selbst kann es mehrere verknüpfte Beiträge geben $postids = array(); $args = array( 'post_type' => $posttypes, // 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 . $field, 'value' => $prdid, 'compare' => '=', 'type' => 'CHAR', ), ), ); // The Query $query = new WP_Query( $args ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); $postids[] = $query->post->ID; } } wp_reset_postdata(); ATKPTools::set_post_setting( $prdid, $posttype . '_postid', $postids ); } } function template_detail_box_content( $post ) { //require_once (ATKP_PLUGIN_DIR.'/includes/models/atkp_shop.php'); //require_once (ATKP_PLUGIN_DIR.'/includes/models/atkp_product.php'); //require_once (ATKP_PLUGIN_DIR.'/includes/models/atkp_template.php'); ?>