$type ) { add_meta_box( 'amazonProductInAPostBox_' . $type, __( 'Amazon Product In a Post Settings', 'amazon-product-in-a-post-plugin' ), 'amazonProductInAPostBox1', $type, $context, $priority ); } } } } function appip_post_type_support() { $types = apply_filters( 'appip_meta_posttypes_support', array( 'page', 'post' ) ); add_appip_meta_posttype_support( $types ); } add_filter( 'admin_enqueue_scripts', 'appip_post_type_support', 20 ); function appip_add_product_meta_support($types =array()){ $types[] = 'product'; return $types; } add_filter( 'appip_meta_posttypes_support', 'appip_add_product_meta_support',10); function appip_plugin_help( $contextual_help, $screen_id, $screen ) { $plugin_donate = 0; switch ( $screen_id ) { case 'toplevel_page_apipp-main-menu': $contextual_help = __( 'Plugin Settings Contextual Help Coming Soon.', 'amazon-product-in-a-post-plugin' ); $plugin_donate = 1; break; case 'amazon-product_page_apipp-add-new': $contextual_help = __( 'New Product Contextual Help Coming Soon.', 'amazon-product-in-a-post-plugin' ); $plugin_donate = 1; break; case 'amazon-product_page_apipp-main-menu': $contextual_help = __( 'Plugin Settings Contextual Help Coming Soon.', 'amazon-product-in-a-post-plugin' ); $plugin_donate = 1; break; case 'amazon-product_page_apipp_plugin_admin': $contextual_help = __( 'Plugin Settings Contextual Help Coming Soon.', 'amazon-product-in-a-post-plugin' ); $plugin_donate = 1; break; case 'amazon-product_page_apipp_plugin-shortcode': $contextual_help = __( 'Shortcode Usage Contextual Help Coming Soon.', 'amazon-product-in-a-post-plugin' ); $plugin_donate = 1; break; case 'amazon-product_page_apipp_plugin-faqs': $contextual_help = __( 'FAQs/Help Contextual Help Coming Soon.', 'amazon-product-in-a-post-plugin' ); $plugin_donate = 1; break; case 'amazon-product_page_apipp-cache-page': $contextual_help = __( 'Product Cache Contextual Help Coming Soon.', 'amazon-product-in-a-post-plugin' ); $plugin_donate = 1; break; } if ( $plugin_donate == 1 ) { $screen->add_help_tab( array( 'id' => 'appip_aboutus', 'title' => __( 'About Us', 'amazon-product-in-a-post-plugin' ), 'content' => '

' . __( 'Fischer Creative Media, LLC develops custom WordPress Themes and Plugins for clients who need a more individualized look, but still want the simplicity of a WordPress website.', 'amazon-product-in-a-post-plugin' ) ) ); $screen->set_help_sidebar( '

' . __( 'For more information:', 'amazon-product-in-a-post-plugin' ) . '

' . '

' . __( 'Donate to this Plugin', 'amazon-product-in-a-post-plugin' ) . '

' . '

' . __( 'See Our Other WordPress Plugins', 'amazon-product-in-a-post-plugin' ) . '

' ); } return $contextual_help; } function appip_warning_notice() { if ( isset( $_REQUEST[ 'dismissmsg' ] ) && $_REQUEST[ 'dismissmsg' ] == '1' ) { update_option( 'appip_dismiss_msg', 1 ); } $appip_publickey = APIAP_PUB_KEY; $appip_privatekey = APIAP_SECRET_KEY; $appip_partner_id = APIAP_ASSOC_ID; $appip_dismiss = get_option( 'appip_dismiss_msg', 0 ); if ( $appip_dismiss == 0 ) { if ( $appip_publickey == '' || $appip_privatekey == '' ) { echo '

' . __( 'Amazon Product in a Post Important Message!', 'amazon-product-in-a-post-plugin' ) . '

' . __( 'Please note: You need to add your Access Key ID and Secrect Access Key to the options page before the plugin will display any Amazon Products!dismiss', 'amazon-product-in-a-post-plugin' ) . '

'; } elseif ( $appip_partner_id == '' ) { echo '

' . __( 'Amazon Product in a Post Important Message!', 'amazon-product-in-a-post-plugin' ) . '

' . __( 'You need to enter your Amazon Partner ID in order to get credit for any products sold. enter your partner id heredismiss', 'amazon-product-in-a-post-plugin' ) . '

'; } } } function apipp_parse_new() { //Custom Save Post items for Quick Add if ( isset( $_POST[ 'createpost' ] ) || isset( $_POST[ 'createpost_edit' ] ) ) { //form saved global $post; $teampappcats = array(); $totalcategories = isset( $_POST[ 'post_category_count' ] ) ? absint( $_POST[ 'post_category_count' ] ) : 0; $post_stat = isset( $_POST[ 'post_status' ] ) ? sanitize_text_field( $_POST[ 'post_status' ] ) : 'draft'; $post_type = isset( $_POST[ 'post_type' ] ) ? sanitize_text_field( $_POST[ 'post_type' ] ) : 'post'; $splitASINs = isset( $_POST[ 'split_asins' ] ) && ( int )$_POST[ 'split_asins' ] == 1 ? true : false; $allowed_tags = wp_kses_allowed_html( $post_type ); $ASIN = isset( $_POST[ 'amazon-product-single-asin' ] ) ? str_replace( ', ', ',', sanitize_text_field( $_POST[ 'amazon-product-single-asin' ] ) ) : ''; $amzArr = array(); $amzreq = ''; if ( $ASIN != '' ) { $inCache = amazon_product_check_in_cache( $asin ); $ASIN = ( is_array( $ASIN ) && !empty( $ASIN ) ) ? implode( ',', $ASIN ) : $ASIN; //valid ASIN or ASINs $asinR = explode( ",", $ASIN ); $asinArr = $asinR; $errors = ''; if ( $inCache ) $pxmlNew = amazon_plugin_aws_signed_request( APIAP_LOCALE, array( "Operation" => "ItemLookup", "ItemId" => $ASIN, "ResponseGroup" => "Large,Reviews,VariationSummary", "IdType" => "ASIN", "AssociateTag" => APIAP_ASSOC_ID, "RequestBy" => 'amazon-elements' ), APIAP_PUB_KEY, APIAP_SECRET_KEY, true ); else $pxmlNew = amazon_plugin_aws_signed_request( APIAP_LOCALE, array( "Operation" => "ItemLookup", "ItemId" => $ASIN, "ResponseGroup" => "Large,Reviews,VariationSummary", "IdType" => "ASIN", "AssociateTag" => APIAP_ASSOC_ID, "RequestBy" => 'amazon-elements' ), APIAP_PUB_KEY, APIAP_SECRET_KEY ); $totalResult1 = array(); $totalResult2 = array(); $errorsArr = array(); $doedit = isset( $_REQUEST[ 'createpost_edit' ] ) && $_REQUEST[ 'createpost_edit' ] != '' ? true : false; $red_location = ''; if ( is_array( $pxmlNew ) && !empty( $pxmlNew ) ) { $pxmle = array(); foreach ( $pxmlNew as $pxmlkey => $pxml ) { if ( !is_array( $pxml ) ) { $pxmle = $pxml; } else { $r1 = appip_plugin_FormatASINResult( $pxml, 0, $asinR ); if ( is_array( $r1 ) && !empty( $r1 ) ) { foreach ( $r1 as $ritem ) { $totalResult1[] = $ritem; } } $r2 = appip_plugin_FormatASINResult( $pxml, 1, $asinR ); if ( is_array( $r2 ) && !empty( $r2 ) ) { foreach ( $r2 as $ritem2 ) { $totalResult2[] = $ritem2; } } } } } } if ( !empty( $pxmle ) ) { $pxml = $pxmle; return false; } else { $resultarr = array(); $resultarr1 = isset( $totalResult1 ) && !empty( $totalResult1 ) ? $totalResult1 : array(); //appip_plugin_FormatASINResult( $pxml ); $resultarr2 = isset( $totalResult2 ) && !empty( $totalResult2 ) ? $totalResult2 : array(); //appip_plugin_FormatASINResult( $pxml, 1 ); if ( is_array( $resultarr1 ) && !empty( $resultarr1 ) ) { foreach ( $resultarr1 as $key1 => $result1 ): $mainAArr = ( array )$result1; $otherArr = ( array )$resultarr2[ $key1 ]; $resultarr[ $key1 ] = ( array )array_merge( $mainAArr, $otherArr ); ksort( $resultarr[ $key1 ] ); endforeach; } } if ( is_array( $asinArr ) && !empty( $asinArr ) ) { foreach ( $asinArr as $checkASIN ) { foreach ( $resultarr as $resV ) { if ( isset( $resV[ 'ASIN' ] ) ) { //uses Amazon Title & Content if Title & Content is empty. $tasin = $resV[ 'ASIN' ]; $tempCS = isset( $resV[ 'ItemDesc' ][ 0 ][ 'Source' ] ) ? $resV[ 'ItemDesc' ][ 0 ][ 'Source' ] : ''; $tempCS = $tempCS == '' && isset( $resV[ 'ItemDesc' ][ 'Source' ] ) ? $resV[ 'ItemDesc' ][ 'Source' ] : $tempCS; $tempCT = isset( $resV[ 'ItemDesc' ][ 0 ][ 'Content' ] ) && $tempCS == 'Product Description' ? str_replace( array( '' ), array( '', '' ), $resV[ 'ItemDesc' ][ 0 ][ 'Content' ] ) : ''; $tempCT = $tempCT == '' && isset( $resV[ 'ItemDesc' ][ 'Content' ] ) && $tempCS == 'Product Description' ? str_replace( array( '' ), array( '', '' ), $resV[ 'ItemDesc' ][ 'Content' ] ) : $tempCT; $temptitle = isset( $resV[ 'Title' ] ) ? $resV[ 'Title' ] : 'Product ' . $tasin; if ( $splitASINs && count( $asinArr ) > 1 ) { $postTitle = isset( $_POST[ 'post_title' ] ) && $_POST[ 'post_title' ] != '' ? sanitize_text_field( $_POST[ 'post_title' ] ) . ' (' . $tasin . ')': $temptitle; $asinContent = $tempCT != '' ? wp_kses( $tempCT, $allowed_tags ) : ''; $manualContent = isset( $_POST[ 'post_content' ] ) && $_POST[ 'post_content' ] != '' ? wp_kses( $_POST[ 'post_content' ], $allowed_tags ) : ''; $postContent = $manualContent != '' ? $manualContent : ''; $postContent = $asinContent != '' ? $postContent . "\n" . $asinContent: $postContent; $postContent = $postContent == '' ? 'Content ' . $tasin : $postContent; } else { $postTitle = isset( $_POST[ 'post_title' ] ) && $_POST[ 'post_title' ] != '' ? sanitize_text_field( $_POST[ 'post_title' ] ) : $temptitle; $asinContent = $tempCT != '' ? wp_kses( $tempCT, $allowed_tags ) : ''; $manualContent = isset( $_POST[ 'post_content' ] ) && $_POST[ 'post_content' ] != '' ? wp_kses( $_POST[ 'post_content' ], $allowed_tags ) : ''; $postContent = $manualContent != '' ? $manualContent : ''; $postContent = $asinContent != '' ? $postContent . "\n" . $asinContent: $postContent; $postContent = $postContent == '' ? 'Content ' . $tasin : $postContent; } $newProds[ $resV[ 'ASIN' ] ][ 'Title' ] = $postTitle; $newProds[ $resV[ 'ASIN' ] ][ 'Content' ] = $postContent; $postImage = isset( $resV[ 'LargeImage_URL' ] ) ? $resV[ 'LargeImage_URL' ] : ''; $postImageH = $postImage != '' && isset( $resV[ 'LargeImage_Height_value' ] ) ? $resV[ 'LargeImage_Height_value' ] . 'px': ''; $postImageH = $postImageH == '' && $postImage != '' && isset( $resV[ 'LargeImage_Height' ] ) ? $resV[ 'LargeImage_Height' ] . 'px': ''; $postImageW = $postImage != '' && isset( $resV[ 'LargeImage_Width_value' ] ) ? $resV[ 'LargeImage_Width_value' ] . 'px': ''; $postImageW = $postImageW == '' && $postImage != '' && isset( $resV[ 'LargeImage_Width' ] ) ? $resV[ 'LargeImage_Width' ] . 'px': ''; $newProds[ $resV[ 'ASIN' ] ][ 'LargeImage_URL' ] = $postImage; $newProds[ $resV[ 'ASIN' ] ][ 'LargeImage_Height_value' ] = $postImageH; $newProds[ $resV[ 'ASIN' ] ][ 'LargeImage_Width_value' ] = $postImageW; } } } } else { $tasin = $ASIN; $tempCS = isset( $resultarr[ 'ItemDesc' ][ 0 ][ 'Source' ] ) ? $resultarr[ 'ItemDesc' ][ 0 ][ 'Source' ] : ''; $tempCS = $tempCS == '' && isset( $resultarr[ 'ItemDesc' ][ 'Source' ] ) ? $resultarr[ 'ItemDesc' ][ 'Source' ] : ''; $tempCT = isset( $resultarr[ 'ItemDesc' ][ 0 ][ 'Content' ] ) && $tempCS == 'Product Description' ? str_replace( array( '' ), array( '', '' ), $resultarr[ 'ItemDesc' ][ 0 ][ 'Content' ] ) : ''; $tempCT = $tempCT == '' && isset( $resultarr[ 'ItemDesc' ][ 'Content' ] ) && $tempCS == 'Product Description' ? str_replace( array( '' ), array( '', '' ), $resultarr[ 'ItemDesc' ][ 'Content' ] ) : ''; $temptitle = isset( $resultarr[ 'Title' ] ) ? $resultarr[ 'Title' ] : 'Product ' . $tasin; $postTitle = isset( $_POST[ 'post_title' ] ) && $_POST[ 'post_title' ] != '' ? sanitize_text_field( $_POST[ 'post_title' ] ) : $temptitle; $asinContent = $tempCT != '' ? wp_kses( $tempCT, $allowed_tags ) : ''; $manualContent = isset( $_POST[ 'post_content' ] ) && $_POST[ 'post_content' ] != '' ? wp_kses( $_POST[ 'post_content' ], $allowed_tags ) : ''; $postContent = $manualContent != '' ? $manualContent : ''; $postContent = $asinContent != '' ? $postContent . "\n" . $asinContent: $postContent; $postContent = $postContent == '' ? 'Content ' . $tasin : $postContent; $newProds[ $resultarr[ 'ASIN' ] ][ 'Title' ] = $postTitle; $newProds[ $resultarr[ 'ASIN' ] ][ 'Content' ] = $postContent; //$postImage = isset($resultarr['LargeImage_URL']) ? $resultarr['LargeImage_URL'] : ''; $postImage = isset( $resV[ 'LargeImage_URL' ] ) ? $resV[ 'LargeImage_URL' ] : ''; $postImageH = $postImage != '' && isset( $resV[ 'LargeImage_Height_value' ] ) ? $resV[ 'LargeImage_Height_value' ] . 'px': ''; $postImageH = $postImageH == '' && $postImage != '' && isset( $resV[ 'LargeImage_Height' ] ) ? $resV[ 'LargeImage_Height' ] . 'px': ''; $postImageW = $postImage != '' && isset( $resV[ 'LargeImage_Width_value' ] ) ? $resV[ 'LargeImage_Width_value' ] . 'px': ''; $postImageW = $postImageW == '' && $postImage != '' && isset( $resV[ 'LargeImage_Width' ] ) ? $resV[ 'LargeImage_Width' ] . 'px': ''; $newProds[ $resultarr[ 'ASIN' ] ][ 'LargeImage_URL' ] = $postImage; $newProds[ $resultarr[ 'ASIN' ] ][ 'LargeImage_Height_value' ] = $postImageH; $newProds[ $resultarr[ 'ASIN' ] ][ 'LargeImage_Width_value' ] = $postImageW; } if ( $splitASINs && count( $asinArr ) > 1 ) { $createdpostid = array(); foreach ( $asinArr as $checkASIN ) { $postTitle = isset( $newProds[ $checkASIN ][ 'Title' ] ) ? $newProds[ $checkASIN ][ 'Title' ] : 'Product ' . $checkASIN; $postContent = isset( $newProds[ $checkASIN ][ 'Content' ] ) ? '[amazon-element asin="' . $checkASIN . '" field="desc"]' /*$newProds[$checkASIN]['Content'] */: ''; /*'Content '. $checkASIN;*/ $postImage = isset( $newProds[ $checkASIN ][ 'LargeImage_URL' ] ) ? $newProds[ $checkASIN ][ 'LargeImage_URL' ] : ''; $postImageH = $postImage != '' && isset( $newProds[ $checkASIN ][ 'LargeImage_Height_value' ] ) ? $newProds[ $checkASIN ][ 'LargeImage_Height_value' ] . 'px': ''; $postImageW = $postImage != '' && isset( $newProds[ $checkASIN ][ 'LargeImage_Width_value' ] ) ? $newProds[ $checkASIN ][ 'LargeImage_Width_value' ] . 'px': ''; if ( isset( $_POST[ 'post_category' ][ $post_type ] ) && is_array( $_POST[ 'post_category' ][ $post_type ] ) && !empty( $_POST[ 'post_category' ][ $post_type ] ) ) { foreach ( $_POST[ 'post_category' ][ $post_type ] as $key => $val ) { $post_array = array( 'post_author' => ( isset( $_POST[ 'post_author' ] ) ? absint( $_POST[ 'post_author' ] ) : '' ), 'post_title' => $postTitle, 'post_status' => $post_stat, 'post_type' => $post_type, 'post_content' => $postContent, ); $createdpostid[ $checkASIN ] = wp_insert_post( $post_array ); $val = array_unique( array_map( 'intval', $val ) ); if ( $postImage != '' ) { $featured_key = apply_filters( 'amazon_featured_post_meta_key', '_amazon_featured_url' ); $featured_h_key = '_amazon_featured_height'; $featured_w_key = '_amazon_featured_width'; $alt_key = '_amazon_featured_alt'; $postid = $createdpostid[ $checkASIN ]; delete_post_meta( $postid, $featured_key ); delete_post_meta( $postid, $featured_h_key ); delete_post_meta( $postid, $featured_w_key ); delete_post_meta( $postid, $alt_key ); update_post_meta( $postid, $featured_key, $postImage, true ); if ( $postImageH != '' ) update_post_meta( $postid, $featured_h_key, $postImageH, true ); if ( $postImageW != '' ) update_post_meta( $postid, $featured_w_key, $postImageW, true ); if ( $postTitle != 'Product ' . $checkASIN ) update_post_meta( $postid, $alt_key, $postTitle, true ); } $tesrr = wp_set_post_terms( $createdpostid, $val, $key, false ); } } else { $post_array = array( 'post_author' => sanitize_text_field( $_POST[ 'post_author' ] ), 'post_title' => $postTitle, 'post_status' => $post_stat, 'post_type' => $post_type, 'post_content' => $postContent, 'post_parent' => 0, 'post_category' => '' ); $createdpostid[ $checkASIN ] = wp_insert_post( $post_array, 'false' ); if ( $postImage != '' ) { $featured_key = apply_filters( 'amazon_featured_post_meta_key', '_amazon_featured_url' ); $featured_h_key = '_amazon_featured_height'; $featured_w_key = '_amazon_featured_width'; $alt_key = '_amazon_featured_alt'; $postid = $createdpostid[ $checkASIN ]; delete_post_meta( $postid, $featured_key ); delete_post_meta( $postid, $featured_h_key ); delete_post_meta( $postid, $featured_w_key ); delete_post_meta( $postid, $alt_key ); update_post_meta( $postid, $featured_key, $postImage, true ); if ( $postImageH != '' ) update_post_meta( $postid, $featured_h_key, $postImageH, true ); if ( $postImageW != '' ) update_post_meta( $postid, $featured_w_key, $postImageW, true ); if ( $postTitle != 'Product ' . $checkASIN ) update_post_meta( $postid, $alt_key, $postTitle, true ); } } } if ( is_array( $createdpostid ) && !empty( $createdpostid ) ) { foreach ( $createdpostid as $key => $pid ) { $newpost = get_post( $pid ); ini_set( 'display_errors', 0 ); amazonProductInAPostSavePostdata( $pid, $newpost, $key ); } $red_location = "Location: admin.php?page=apipp-add-new&appmsg=1&qty=" . count( $createdpostid ); $red_pid = $createdpostid; //header( "Location: admin.php?page=apipp-add-new&appmsg=1&qty=".count($createdpostid) ); //exit(); } else { $red_location = "Location: admin.php?page=apipp-add-new&appmsg=2"; $red_pid = 0; //header( "Location: admin.php?page=apipp-add-new&appmsg=2" ); //exit(); } } else { $postTitle = isset( $newProds[ $asinArr[ 0 ] ][ 'Title' ] ) ? $newProds[ $asinArr[ 0 ] ][ 'Title' ] : ''; $postContent = isset( $newProds[ $asinArr[ 0 ] ][ 'Content' ] ) ? '[amazon-element asin="' . $asinArr[ 0 ] . '" field="desc"]' /*$newProds[$checkASIN]['Content'] */: ''; /*'Content '. $checkASIN;*/ //$postContent = isset($newProds[$asinArr[0]]['Content']) ? $newProds[$asinArr[0]]['Content'] : 'Content '. $asinArr[0]; $postImage = isset( $newProds[ $asinArr[ 0 ] ][ 'LargeImage_URL' ] ) ? $newProds[ $asinArr[ 0 ] ][ 'LargeImage_URL' ] : ''; $postImageH = $postImage != '' && isset( $newProds[ $asinArr[ 0 ] ][ 'LargeImage_Height_value' ] ) ? $newProds[ $asinArr[ 0 ] ][ 'LargeImage_Height_value' ] . 'px': ''; $postImageW = $postImage != '' && isset( $newProds[ $asinArr[ 0 ] ][ 'LargeImage_Width_value' ] ) ? $newProds[ $asinArr[ 0 ] ][ 'LargeImage_Width_value' ] . 'px': ''; if ( isset( $_POST[ 'post_category' ][ $post_type ] ) ) { foreach ( $_POST[ 'post_category' ][ $post_type ] as $key => $val ) { $post_array = array( 'post_author' => ( isset( $_POST[ 'post_author' ] ) ? absint( $_POST[ 'post_author' ] ) : '' ), 'post_title' => $postTitle, 'post_status' => $post_stat, 'post_type' => $post_type, 'post_content' => $postContent, ); $createdpostid = wp_insert_post( $post_array ); $val = array_unique( array_map( 'intval', $val ) ); if ( $postImage != '' ) { $featured_key = apply_filters( 'amazon_featured_post_meta_key', '_amazon_featured_url' ); $featured_h_key = '_amazon_featured_height'; $featured_w_key = '_amazon_featured_width'; $alt_key = '_amazon_featured_alt'; $postid = $createdpostid; delete_post_meta( $postid, $featured_key ); delete_post_meta( $postid, $featured_h_key ); delete_post_meta( $postid, $featured_w_key ); delete_post_meta( $postid, $alt_key ); update_post_meta( $postid, $featured_key, $postImage, true ); if ( $postImageH != '' ) update_post_meta( $postid, $featured_h_key, $postImageH, true ); if ( $postImageW != '' ) update_post_meta( $postid, $featured_w_key, $postImageW, true ); if ( $postTitle != 'Product ' . $asinArr[ 0 ] ) update_post_meta( $postid, $alt_key, $postTitle, true ); } $tesrr = wp_set_post_terms( $createdpostid, $val, $key, false ); } } else { $post_array = array( 'post_author' => sanitize_text_field( $_POST[ 'post_author' ] ), 'post_title' => $postTitle, 'post_status' => $post_stat, 'post_type' => $post_type, 'post_content' => $postContent, 'post_parent' => 0, 'post_category' => '' ); $createdpostid = wp_insert_post( $post_array, 'false' ); if ( $postImage != '' ) { $featured_key = apply_filters( 'amazon_featured_post_meta_key', '_amazon_featured_url' ); $featured_h_key = '_amazon_featured_height'; $featured_w_key = '_amazon_featured_width'; $alt_key = '_amazon_featured_alt'; $postid = $createdpostid; delete_post_meta( $postid, $featured_key ); delete_post_meta( $postid, $featured_h_key ); delete_post_meta( $postid, $featured_w_key ); delete_post_meta( $postid, $alt_key ); update_post_meta( $postid, $featured_key, $postImage, true ); if ( $postImageH != '' ) update_post_meta( $postid, $featured_h_key, $postImageH, true ); if ( $postImageW != '' ) update_post_meta( $postid, $featured_w_key, $postImageW, true ); if ( $postTitle != 'Product ' . $asinArr[ 0 ] ) update_post_meta( $postid, $alt_key, $postTitle, true ); } } if ( $createdpostid != '' ) { $newpost = get_post( $createdpostid ); ini_set( 'display_errors', 0 ); amazonProductInAPostSavePostdata( $createdpostid, $newpost, $asinArr[ 0 ] ); $red_location = "Location: admin.php?page=apipp-add-new&appmsg=1&asins=" . implode( ",", $asinArr ); $red_pid = $createdpostid; //header("Location: admin.php?page=apipp-add-new&appmsg=1&asins=".implode(",",$asinArr)); //exit(); } else { $red_location = "Location: admin.php?page=apipp-add-new&appmsg=2"; $red_pid = 0; //header("Location: admin.php?page=apipp-add-new&appmsg=2"); //exit(); } } if ( is_array( $red_pid ) && $red_location != '' ) { header( $red_location ); exit(); } elseif ( $red_pid != 0 ) { if ( $doedit ) { $red_location = "Location: post.php?post={$red_pid}&action=edit"; header( $red_location ); exit(); } else { header( $red_location ); exit(); } } else { } } else { add_action( 'save_post', 'amazonProductInAPostSavePostdata', 1, 2 ); // save the custom fields } } /* When the post is saved, saves our custom data */ function amazonProductInAPostSavePostdata( $post_id, $post, $asin = '' ) { if ( !isset( $_POST[ 'post_save_type_apipp' ] ) ) return; $post_id = $post_id == '' ? $post->ID : $post_id; $mydata = array(); $mydata[ 'amazon-product-isactive' ] = isset( $_POST[ 'amazon-product-isactive' ] ) ? sanitize_text_field( $_POST[ 'amazon-product-isactive' ] ) : '0'; $mydata[ 'amazon-product-content-location' ] = isset( $_POST[ 'amazon-product-content-location' ][ 1 ][ 0 ] ) ? sanitize_text_field( $_POST[ 'amazon-product-content-location' ][ 1 ][ 0 ] ) : '1'; $mydata[ 'amazon-product-single-asin' ] = $asin != '' ? $asin : ( isset( $_POST[ 'amazon-product-single-asin' ] ) ? sanitize_text_field( $_POST[ 'amazon-product-single-asin' ] ) : '' ); $mydata[ 'amazon-product-excerpt-hook-override' ] = isset( $_POST[ 'amazon-product-excerpt-hook-override' ] ) ? sanitize_text_field( $_POST[ 'amazon-product-excerpt-hook-override' ] ) : '3'; $mydata[ 'amazon-product-content-hook-override' ] = isset( $_POST[ 'amazon-product-content-hook-override' ] ) ? sanitize_text_field( $_POST[ 'amazon-product-content-hook-override' ] ) : '3'; $mydata[ 'amazon-product-newwindow' ] = isset( $_POST[ 'amazon-product-newwindow' ] ) ? sanitize_text_field( $_POST[ 'amazon-product-newwindow' ] ) : '3'; $mydata[ 'amazon-product-singular-only' ] = isset( $_POST[ 'amazon-product-singular-only' ] ) ? sanitize_text_field( $_POST[ 'amazon-product-singular-only' ] ) : '0'; $mydata[ 'amazon-product-amazon-desc' ] = isset( $_POST[ 'amazon-product-amazon-desc' ] ) ? sanitize_text_field( $_POST[ 'amazon-product-amazon-desc' ] ) : '0'; $mydata[ 'amazon-product-show-gallery' ] = isset( $_POST[ 'amazon-product-show-gallery' ] ) ? sanitize_text_field( $_POST[ 'amazon-product-show-gallery' ] ) : '0'; $mydata[ 'amazon-product-show-features' ] = isset( $_POST[ 'amazon-product-show-features' ] ) ? sanitize_text_field( $_POST[ 'amazon-product-show-features' ] ) : '0'; $mydata[ 'amazon-product-show-list-price' ] = isset( $_POST[ 'amazon-product-show-list-price' ] ) ? sanitize_text_field( $_POST[ 'amazon-product-show-list-price' ] ) : '0'; $mydata[ 'amazon-product-show-used-price' ] = isset( $_POST[ 'amazon-product-show-used-price' ] ) ? sanitize_text_field( $_POST[ 'amazon-product-show-used-price' ] ) : '0'; //$mydata['amazon-product-show-saved-amt'] = isset($_POST['amazon-product-show-saved-amt']) ? sanitize_text_field($_POST['amazon-product-show-saved-amt']) : '0'; //$mydata['amazon-product-timestamp'] = isset($_POST['amazon-product-timestamp']) ? sanitize_text_field($_POST['amazon-product-timestamp']) : '0'; $mydata[ 'amazon-product-new-title' ] = isset( $_POST[ 'amazon-product-new-title' ] ) ? sanitize_text_field( $_POST[ 'amazon-product-new-title' ] ) : ''; $mydata[ 'amazon-product-use-cartURL' ] = isset( $_POST[ 'amazon-product-use-cartURL' ] ) && ( int )$_POST[ 'amazon-product-use-cartURL' ] == 1 ? '1' : ''; if ( $mydata[ 'amazon-product-isactive' ] == '' && $mydata[ 'amazon-product-single-asin' ] == "" ) { $mydata[ 'amazon-product-content-location' ] = ''; } if ( $mydata[ 'amazon-product-excerpt-hook-override' ] == '' ) { $mydata[ 'amazon-product-excerpt-hook-override' ] = '3'; } if ( $mydata[ 'amazon-product-content-hook-override' ] == '' ) { $mydata[ 'amazon-product-content-hook-override' ] = '3'; } if ( $mydata[ 'amazon-product-newwindow' ] == '' ) { $mydata[ 'amazon-product-newwindow' ] = '3'; } $mydata = apply_filters( 'amazon_product_in_a_post_plugin_meta_presave', $mydata ); foreach ( $mydata as $key => $value ) { if ( isset( $post->post_type ) && $post->post_type == 'revision' ) { return; } $value = implode( ',', ( array )$value ); if ( get_post_meta( $post_id, $key, FALSE ) ) { update_post_meta( $post_id, $key, $value ); } else { add_post_meta( $post_id, $key, $value ); } if ( !$value )delete_post_meta( $post_id, $key ); //delete if blank } } /* Prints the inner fields for the custom post/page section */ function amazonProductInAPostBox1() { global $post; $appASIN = get_post_meta( $post->ID, 'amazon-product-single-asin', true ); $appnewwin = get_post_meta( $post->ID, 'amazon-product-newwindow', true ); $appsingle = get_post_meta( $post->ID, 'amazon-product-singular-only', true ); $appnewinO = get_option( 'apipp_open_new_window' ) == true ? 1 : 0; $apphookO = get_option( 'apipp_hook_excerpt' ) == true ? 1 : 0; $apphook = get_post_meta( $post->ID, 'amazon-product-excerpt-hook-override', true ); $appcont = get_post_meta( $post->ID, 'amazon-product-content-hook-override', true ); $appcontO = get_option( 'apipp_hook_content' ) == true ? 1 : 0; $appactive = get_post_meta( $post->ID, 'amazon-product-isactive', true ); $appaffidO = APIAP_ASSOC_ID; $appnoonce = wp_create_nonce( plugin_basename( __FILE__ ) ); // Use nonce for verification ... ONLY USE ONCE! $appconloc = get_post_meta( $post->ID, 'amazon-product-content-location', true ); $amazondesc = get_post_meta( $post->ID, 'amazon-product-amazon-desc', true ); $amazongallery = get_post_meta( $post->ID, 'amazon-product-show-gallery', true ); $amazonfeatures = get_post_meta( $post->ID, 'amazon-product-show-features', true ); $amazontstamp = get_post_meta( $post->ID, 'amazon-product-timestamp', true ); $appipnewtitle = get_post_meta( $post->ID, 'amazon-product-new-title', true ); $amazonused = get_post_meta( $post->ID, 'amazon-product-show-used-price', true ); $amazonlist = get_post_meta( $post->ID, 'amazon-product-show-list-price', true ); $amazonsaved = get_post_meta( $post->ID, 'amazon-product-show-saved-amt', true ); $useCartURL = get_post_meta( $post->ID, 'amazon-product-use-cartURL', true ); $menuhide = ( $appactive != '' ) ? ' checked="checked"' : ''; $hookcontent = ( $appcont == '2' || ( $appcont == '' && $appcontO ) ) ? ' checked="checked"' : ""; $hookexcerpt = ( $apphook == '2' || ( $apphook == '' && $apphookO ) ) ? ' checked="checked"' : ""; $singleonly = ( $appsingle == '1' ) ? ' checked="checked"' : ""; $newwin = ( $appnewwin == '2' || ( $appnewwin == '' && $appnewinO ) ) ? ' checked="checked"' : ""; $amazontstamp = $amazontstamp != '' ? ' checked="checked"' : ''; $amazondesc = $amazondesc != '' ? ' checked="checked"' : ''; $amazongallery = $amazongallery != '' ? ' checked="checked"' : ''; $amazonfeatures = $amazonfeatures != '' ? ' checked="checked"' : ''; $amazonused = $amazonused != '' ? ' checked="checked"' : ''; $amazonlist = $amazonlist != '' ? ' checked="checked"' : ''; $amazonsaved = $amazonsaved != '' ? ' checked="checked"' : ''; $useCartURL = $useCartURL != '' ? ' checked="checked"' : ''; if ( $appconloc === '3' ) { $appeampleimg = 'example-layout-3.png'; } elseif ( $appconloc === '2' ) { $appeampleimg = 'example-layout-2.png'; } else { $appeampleimg = 'example-layout-1.png'; } $noaffidmsg = '

' . __( 'WARNING:', 'amazon-product-in-a-post-plugin', 'amazon-product-in-a-post-plugin' ) . ' ' . __( 'You will not get credit for Amazon purchases until you add your Amazon Affiliate ID on the options page.', 'amazon-product-in-a-post-plugin' ) . '

'; if ( $appaffidO == '' ) { echo $noaffidmsg; } echo '

' . __( 'if checked the product will be live', 'amazon-product-in-a-post-plugin' ) . '

'; echo '


' . __( 'For multiple, separate with a comma. You will need to get ASINs from Amazon', 'amazon-product-in-a-post-plugin' ) . '

'; echo '

' . __( 'Optional. To hide title all together, type "null". No HTML, plain text only. Use this if you want your own title to show instead of Amazon\'s title.', 'amazon-product-in-a-post-plugin' ) . '

'; echo ''; echo '

' . __( 'Product will show when full content is used (when the_content() template tag). On by default.', 'amazon-product-in-a-post-plugin' ) . '

'; echo '

' . __( 'Product will show when partial excerpt content is used(when the_excerpt() is used. Off by default.', 'amazon-product-in-a-post-plugin' ) . '

'; echo '

' . __( 'if checked the product will only show when on single page. Off by default.', 'amazon-product-in-a-post-plugin' ) . '

'; echo '

' . __( 'if checked the product will open a new browser window. Off by default unless set in options.', 'amazon-product-in-a-post-plugin' ) . '

'; echo '
'; echo '

'; echo '

     ' . __( 'Above Post Content - Default - Product will be first then post text', 'amazon-product-in-a-post-plugin' ) . '
'; echo '     ' . __( 'Below Post Content - Post text will be first then the Product', 'amazon-product-in-a-post-plugin' ) . '
'; echo '     ' . __( 'Post Text becomes Description - Post text will become part of the Product layout', 'amazon-product-in-a-post-plugin' ) . '

'; echo '

Additional Features:

'; echo '

' . __( 'Uses Add to Cart URL instead of product page link. helps with 90 day conversion cookie.', 'amazon-product-in-a-post-plugin' ) . '

'; echo '

' . __( 'if available. This will be IN ADDITION TO your own content.', 'amazon-product-in-a-post-plugin' ) . '

'; echo '

' . __( 'if available (Consists of Amazon Approved images only). Not all products have an Amazon Image Gallery.', 'amazon-product-in-a-post-plugin' ) . '

'; echo '

' . __( 'if available. Not all items have this feature.', 'amazon-product-in-a-post-plugin' ) . '

'; echo '

' . __( 'if available. Not all items have this feature.', 'amazon-product-in-a-post-plugin' ) . '

'; echo '

' . __( 'if available. Not all items have this feature.', 'amazon-product-in-a-post-plugin' ) . '

'; /* Possibly Remove */ //echo '

'.__('if available. Not all items have this feature.','amazon-product-in-a-post-plugin').'

'; //echo '

'.__('for example:','amazon-product-in-a-post-plugin').''.__('

  Amazon.com Price: $32.77 (as of 01/07/2008 14:11 PST - Details)
  Amazon.com Price: $32.77 (as of 14:11 PST - More info)
','amazon-product-in-a-post-plugin').'

'; //echo ''; echo '
'; } /* When the post is saved, saves our custom data */ function amazonProductInAPostSavePostdataForm( $post_id, $post ) { if ( $post_id == '' ) { $post_id = $post->ID; } if ( !isset( $post[ 'post_save_type_apipp' ] ) ) { return; } $mydata = array(); $mydata[ 'amazon-product-isactive' ] = sanitize_text_field( $post[ 'amazon-product-isactive' ] ); $mydata[ 'amazon-product-content-location' ] = sanitize_text_field( $post[ 'amazon-product-content-location' ] ); $mydata[ 'amazon-product-single-asin' ] = sanitize_text_field( $post[ 'amazon-product-single-asin' ] ); $mydata[ 'amazon-product-excerpt-hook-override' ] = sanitize_text_field( $post[ 'amazon-product-excerpt-hook-override' ] ); $mydata[ 'amazon-product-content-hook-override' ] = sanitize_text_field( $post[ 'amazon-product-content-hook-override' ] ); $mydata[ 'amazon-product-newwindow' ] = sanitize_text_field( $post[ 'amazon-product-newwindow' ] ); $mydata[ 'amazon-product-singular-only' ] = sanitize_text_field( $post[ 'amazon-product-singular-only' ] ); $mydata[ 'amazon-product-amazon-desc' ] = sanitize_text_field( $post[ 'amazon-product-amazon-desc' ] ); $mydata[ 'amazon-product-show-gallery' ] = sanitize_text_field( $post[ 'amazon-product-show-gallery' ] ); $mydata[ 'amazon-product-show-features' ] = sanitize_text_field( $post[ 'amazon-product-show-features' ] ); $mydata[ 'amazon-product-show-list-price' ] = sanitize_text_field( $post[ 'amazon-product-show-list-price' ] ); $mydata[ 'amazon-product-show-used-price' ] = sanitize_text_field( $post[ 'amazon-product-show-used-price' ] ); //$mydata['amazon-product-show-saved-amt'] = sanitize_text_field($post['amazon-product-show-saved-amt']); //$mydata['amazon-product-timestamp'] = sanitize_text_field($post['amazon-product-timestamp']); $mydata[ 'amazon-product-new-title' ] = sanitize_text_field( $post[ 'amazon-product-new-title' ] ); $mydata[ 'amazon-product-use-cartURL' ] = sanitize_text_field( $post[ 'amazon-product-use-cartURL' ] ); if ( $mydata[ 'amazon-product-isactive' ] == '' && $mydata[ 'amazon-product-single-asin' ] == "" ) { $mydata[ 'amazon-product-content-location' ] = ''; } if ( $mydata[ 'amazon-product-excerpt-hook-override' ] == '' ) { $mydata[ 'amazon-product-excerpt-hook-override' ] = '3'; } if ( $mydata[ 'amazon-product-content-hook-override' ] == '' ) { $mydata[ 'amazon-product-content-hook-override' ] = '3'; } if ( $mydata[ 'amazon-product-newwindow' ] == '' ) { $mydata[ 'amazon-product-newwindow' ] = '3'; } $mydata = apply_filters( 'amazon_product_in_a_post_plugin_meta_presave', $mydata ); foreach ( $mydata as $key => $value ) { if ( isset( $post->post_type ) && $post->post_type == 'revision' ) { return; } $value = implode( ',', ( array )$value ); if ( get_post_meta( $post_id, $key, FALSE ) ) { update_post_meta( $post_id, $key, $value ); } else { add_post_meta( $post_id, $key, $value ); } if ( !$value )delete_post_meta( $post_id, $key ); //delete if blank } } function apipp_plugin_menu() { global $fullname_apipp, $shortname_apipp, $options_apipp; apipp_options_add_admin_page( $fullname_apipp, $shortname_apipp, $options_apipp ); add_menu_page( __( 'Amazon Product In a Post Plugin', 'amazon-product-in-a-post-plugin' ), _x('Amazon Product', 'Main Menu Title', 'amazon-product-in-a-post-plugin'), 'edit_posts', 'apipp-main-menu', 'apipp_main_page', 'dashicons-amazon' ); //toplevel_page_apipp-main-menu add_submenu_page( 'apipp-main-menu', _x( "Getting Started", 'Page Title','amazon-product-in-a-post-plugin' ), _x( "Getting Started", 'Menu Title', 'amazon-product-in-a-post-plugin' ), 'edit_posts', 'apipp-main-menu', 'apipp_main_page' ); add_submenu_page( 'apipp-main-menu', _x( "New Amazon Post", 'Page Title', 'amazon-product-in-a-post-plugin' ), _x( "New Amazon Post", 'Menu Title', 'amazon-product-in-a-post-plugin' ), 'edit_posts', "apipp-add-new", 'apipp_add_new_post' ); //amazon-product_page_apipp-add-new add_submenu_page( 'apipp-main-menu', _x( "Amazon Product in a Post Options", 'Page Title', 'amazon-product-in-a-post-plugin' ), _x( "Plugin Settings",'Menu Title', 'amazon-product-in-a-post-plugin' ), 'manage_options', "apipp_plugin_admin", 'apipp_options_add_subpage' ); add_submenu_page( 'apipp-main-menu', _x( "Product Cache",'Page Title', 'amazon-product-in-a-post-plugin' ), _x( "Product Cache", 'Menu Title', 'amazon-product-in-a-post-plugin' ), 'edit_posts', "apipp-cache-page", 'apipp_cache_page' ); add_submenu_page( 'apipp-main-menu', _x( "Shortcode Usage", 'Page Title', 'amazon-product-in-a-post-plugin' ), _x( 'Shortcode Usage', 'Menu Title', 'amazon-product-in-a-post-plugin' ), 'manage_options', 'apipp_plugin-shortcode', 'apipp_shortcode_help_page' ); add_submenu_page( 'apipp-main-menu', _x( "FAQs/Help",'Page Title', 'amazon-product-in-a-post-plugin' ), _x( 'FAQs/Help', 'Menu Title', 'amazon-product-in-a-post-plugin' ), 'manage_options', 'apipp_plugin-faqs', 'apipp_options_faq_page' ); //add_submenu_page( 'apipp-main-menu', __('Layout Styles', 'amazon-product-in-a-post-plugin'), __('Layout Styles', 'amazon-product-in-a-post-plugin'), 'manage_options', 'appip-layout-styles', 'apipp_templates'); } function apipp_cache_page() { global $current_user, $wpdb; if ( !current_user_can( 'manage_options' ) ) { wp_die( __( 'You do not have sufficient permissions to access this page.', 'amazon-product-in-a-post-plugin' ) ); } echo '
'; echo '

' . __( 'Amazon Product In A Post CACHE', 'amazon-product-in-a-post-plugin' ) . '

'; if ( isset( $_GET[ 'appmsg' ] ) && ( int )$_GET[ 'appmsg' ] == 1 ) { if ( isset( $_GET[ 'qty' ] ) && ( int )$_GET[ 'qty' ] > 0 ) { echo '

' . esc_attr( ( int )$_GET[ 'qty' ] ) . ' ' . __( 'Product post(s) have been saved. To edit, use the standard Post Edit options.', 'amazon-product-in-a-post-plugin' ) . '

'; } else { echo '

' . __( 'Product post has been saved. To edit, use the standard Post Edit options.', 'amazon-product-in-a-post-plugin' ) . '

'; } } echo '
'; $paged = isset( $_GET[ 'paged' ] ) && ( int )$_GET[ 'paged' ] != 0 ? ( int )$_GET[ 'paged' ] : 1; $limit = 50; $offset = ( $paged - 1 ) * $limit; $ccountsql = "SELECT count(Cache_id) FROM " . $wpdb->prefix . "amazoncache;"; $max_pages = $wpdb->get_var( $ccountsql ); $num_pages = round( ( int )$max_pages / $limit, 0 ); $checksql = "SELECT body,Cache_id,URL,updated,( NOW() - Updated )as Age FROM " . $wpdb->prefix . "amazoncache ORDER BY Updated DESC LIMIT {$offset},{$limit};"; $result = $wpdb->get_results( $checksql ); $cacheSec = ( int )apply_filters( 'amazon_product_post_cache', get_option( 'apipp_amazon_cache_sec', 3600 ) ) / 60; $foundPage = count( $result ); echo '

' . __( 'The product cache is stored for ' . $cacheSec . ' minutes and then deleted automatically. To refetch a product, delete the cache and it will be updated on the next product load.', 'amazon-product-in-a-post-plugin' ) . '

'; echo '
'; echo '
' . __( 'Delete Cache For ALL Products', 'amazon-product-in-a-post-plugin' ) . '
'; $page_links = paginate_links( array( 'base' => add_query_arg( 'paged', '%#%' ), 'format' => '', 'prev_text' => _x( '«', 'Previous Page Character', 'amazon-product-in-a-post-plugin' ), 'next_text' => _x( '»', 'Next Page Character', 'amazon-product-in-a-post-plugin' ), 'total' => $num_pages, 'current' => $paged ) ); echo '
Total Results: ' . $max_pages . ' ' . $page_links . '
'; echo ''; echo ''; echo ''; if ( !empty( $result ) && is_array( $result ) ) { echo ''; $appct = 0; foreach ( $result as $psxml ) { if ( $appct & 1 ) { echo ''; } else { echo ''; } echo ''; echo ''; echo ''; echo ''; echo ''; $appct++; } } else { echo ''; } echo ''; echo '
' . __( 'Cache ID', 'amazon-product-in-a-post-plugin' ) . '' . __( 'Unique Call UI', 'amazon-product-in-a-post-plugin' ) . '' . __( 'Last Updated', 'amazon-product-in-a-post-plugin' ) . '
' . __( 'Cache ID', 'amazon-product-in-a-post-plugin' ) . '' . __( 'Unique Call UI', 'amazon-product-in-a-post-plugin' ) . '' . __( 'Last Updated', 'amazon-product-in-a-post-plugin' ) . '
' . $psxml->Cache_id . '' . $psxml->URL . ' ( show xml cache data )' . $psxml->updated . '' . __( 'delete cache', 'amazon-product-in-a-post-plugin' ) . '
' . __( 'no cached products at this time.', 'amazon-product-in-a-post-plugin' ) . '
'; echo '
' . __( 'Delete Cache For ALL Products', 'amazon-product-in-a-post-plugin' ) . '
'; echo '
'; echo '
'; } function apipp_shortcode_help_page() { if ( !current_user_can( 'manage_options' ) ) { wp_die( __( 'You do not have sufficient permissions to access this page.', 'amazon-product-in-a-post-plugin' ) ); } $current_tab = isset( $_GET[ 'tab' ] ) ? esc_attr( $_GET[ 'tab' ] ) : 'basics'; $pageTxtArr = array(); $pageTxtArr[] = '
'; $pageTxtArr[] = '

' . __( 'Amazon Product In a Post Shortcode Usage', 'amazon-product-in-a-post-plugin' ) . '

'; $pageTxtArr[] = ''; $pageTxtArr[] = '
'; $pageTxtArr[] = ' '; $pageTxtArr[] = ' '; $pageTxtArr[] = ' '; $pageTxtArr[] = ' '; if ( has_filter( 'amazon_product_shortcode_help_content' ) ){ $newcontent = apply_filters( 'amazon_product_shortcode_help_content', array(), $current_tab ); if(is_array($newcontent) && ! empty($newcontent)){ $pageTxtArr[] = implode("\n",$newcontent); } } $pageTxtArr[] = '
'; $pageTxtArr[] = '
'; echo implode( "\n", $pageTxtArr ); unset( $pageTxtArr ); } function apipp_main_page() { global $current_user, $wpdb; if ( !current_user_can( 'manage_options' ) ) { wp_die( __( 'You do not have sufficient permissions to access this page.', 'amazon-product-in-a-post-plugin' ) ); } $current_tab = isset( $_GET[ 'tab' ] ) ? esc_attr( $_GET[ 'tab' ] ) : 'getting-started-one'; $pageTxtArr = array(); $pageTxtArr[] = '
'; $pageTxtArr[] = ' '; $pageTxtArr[] = '

' . __( 'Amazon Product In A Post - GETTING STARTED', 'amazon-product-in-a-post-plugin' ) . '

'; //echo '
'; $pageTxtArr[] = ''; $pageTxtArr[] = '
'; $pageTxtArr[] = ' '; $pageTxtArr[] = ' '; $pageTxtArr[] = ' '; $pageTxtArr[] = ' '; if ( has_filter( 'amazon_product_getting_started_help_content' ) ) $pageTxtArr[] = apply_filters( 'amazon_product_getting_started_help_content', $current_tab ); $pageTxtArr[] = '
'; $pageTxtArr[] = '
'; echo implode( "\n", $pageTxtArr ); unset( $pageTxtArr ); //echo '
'; //echo ''; } function apipp_options_faq_page() { include_once( ABSPATH . WPINC . '/feed.php' ); echo '

' . __( 'Amazon Product in a Post FAQs/Help', 'amazon-product-in-a-post-plugin' ) . '

' . sprintf( __( 'The FAQS are now on a feed that can be updated on the fly. If you have a question and don\'t see an answer, please send an email to %1$s and ask your question. If it is relevant to the plugin, it will be added to the FAQs feed so it will show up here. Please be sure to include the plugin you are asking a question about (Amazon Product in a Post Plugin), the Debugging Key (located on the options page) and any other information like your WordPress version and examples if the plugin is not working correctly for you. THANKS!', 'amazon-product-in-a-post-plugin' ), 'plugins@fischercreativemedia.com' ) . '


'; $rss = fetch_feed( 'http://www.fischercreativemedia.com/?feed=apipp_faqs' ); $linkfaq = array(); $linkcontent = array(); if ( !is_wp_error( $rss ) ): $maxitems = $rss->get_item_quantity( 100 ); $rss_items = $rss->get_items( 0, $maxitems ); endif; $aqr = 0; if ( $maxitems != 0 ) { foreach ( $rss_items as $item ): $aqr++; $linkfaq[] = '
  • ' . esc_html( $item->get_title() ) . '
  • '; $linkcontent[] = '
  • Q. ' . esc_html( $item->get_title() ) . '

    A. ' . $item->get_content() . '
  • '; endforeach; } echo '

    ' . __( 'Table of Contents', 'amazon-product-in-a-post-plugin' ) . '

    '; echo ''; echo '

    ' . __( 'Questions/Answers', 'amazon-product-in-a-post-plugin' ) . '

    '; echo ''; echo '
    '; } function apipp_templates() { echo '
    '; echo '

    ' . __( 'Amazon Styling Options', 'amazon-product-in-a-post-plugin' ) . '

    '; echo '
    '; echo 'This is a future feature.'; echo '
    '; echo '
    '; } function apipp_add_new_post() { global $user_ID; global $current_user; //get_currentuserinfo(); //wp_get_current_user(); $myuserpost = wp_get_current_user()->ID; echo '

    ' . __( 'Add New Amazon Product Post', 'amazon-product-in-a-post-plugin' ) . '

    '; if ( isset( $_GET[ 'appmsg' ] ) && $_GET[ 'appmsg' ] == '1' ) { echo '

    ' . __( 'Product post has been saved. To edit, use the standard Post Edit options.', 'amazon-product-in-a-post-plugin' ) . '

    '; } echo '

    ' . __( 'This function will allow you to add a new post for an Amazon Product - no need to create a post then add the ASIN. Once you add a Product Post, you can edit the information with the normal Post Edit options.', 'amazon-product-in-a-post-plugin' ) . '

    '; $ptypes = get_post_types( array( 'public' => true ) ); $ptypeHTML = '
    '; $taxonomies = get_taxonomies( array(), 'objects' ); $section = ''; $section .= '' . __( 'Category/Taxonomy for Pages', 'amazon-product-in-a-post-plugin' ) . ':'; $section .= '
    ' . __( 'No Categories/Taxonomy Available for Pages.', 'amazon-product-in-a-post-plugin' ) . '
    '; $section .= ''; if ( !empty( $taxonomies ) ) { foreach ( $taxonomies as $key => $taxCat ) { if ( isset( $taxCat->object_type ) && is_array( $taxCat->object_type ) ) { foreach ( $taxCat->object_type as $tcpost ) { if ( in_array( $tcpost, $ptypes ) && ( $tcpost != 'nav_menu_item' && $tcpost != 'attachment' && $tcpost != 'revision' ) ) { $argsapp = array( 'taxonomy' => $key, 'orderby' => 'name', 'hide_empty' => 0 ); $termsapp = get_terms( $key, $argsapp ); $countapp = count( $termsapp ); if ( 'post_format' == $key || 'post_tag' == $key ) {} else { $section .= '' . __( 'Category/Taxonomy for ', 'amazon-product-in-a-post-plugin' ) . $tcpost . ':'; if ( $countapp > 0 ) { foreach ( $termsapp as $term ) { $section .= '
    ' . $term->name . '
    '; } } else { $section .= '
    ' . __( 'No Categories/Taxonomy Available for this Post type.', 'amazon-product-in-a-post-plugin' ) . '
    '; } $section .= ''; } } } } } } if ( !empty( $ptypes ) ) { foreach ( $ptypes as $ptype ) { if ( $ptype != 'nav_menu_item' && $ptype != 'attachment' && $ptype != 'revision' ) { if ( $ptype == 'post' ) { $addlpaaiptxt = ' checked="checked"'; } else { $addlpaaiptxt = ''; } $ptypeHTML .= '
    '; } } } $ptypeHTML .= '
    '; $extrasec = array(); $extrasec[] = '   ' . __( 'Uses Add to Cart URL instead of product page URL. Heps with 90 day conversion cookie.', 'amazon-product-in-a-post-plugin' ) . '
    '; $extrasec[] = '   ' . __( 'if available. This will be IN ADDITION TO your own content.', 'amazon-product-in-a-post-plugin' ) . '
    '; $extrasec[] = '   ' . __( 'if available (Consists of Amazon Approved images only). Not all products have an Amazon Image Gallery.', 'amazon-product-in-a-post-plugin' ) . '
    '; $extrasec[] = '   ' . __( 'if available. Not all items have this feature.', 'amazon-product-in-a-post-plugin' ) . '
    '; $extrasec[] = '   ' . __( 'if available. Not all items have this feature.', 'amazon-product-in-a-post-plugin' ) . '
    '; $extrasec[] = '   ' . __( 'if available. Not all items have this feature.', 'amazon-product-in-a-post-plugin' ) . '
    '; /* possible remove */ //$extrasec[] = '   '.__('if available. Not all items have this feature.','amazon-product-in-a-post-plugin').'
    '; //$extrasec[] = '   '.__('for example:','amazon-product-in-a-post-plugin').'
      '.__('Amazon.com Price: $32.77 (as of 01/07/2018 14:11 PST').' - '.__('Details').')
    '.'
    '; //$extrasec[] = ''; echo '
    ' . $section . '
    ' . __( 'Title', 'amazon-product-in-a-post-plugin' ) . ':
    If you want the post title to be the title of the product, you can leave this blank and the plugin will try to set the product title as the Post title.
    ' . __( 'Post Status', 'amazon-product-in-a-post-plugin' ) . ':
    ' . __( 'Post Type', 'amazon-product-in-a-post-plugin' ) . ': ' . $ptypeHTML . '
    ' . __( 'Amazon ASIN Number', 'amazon-product-in-a-post-plugin' ) . ':  ' . __( 'You can use up to 10 comma separated ASINs.', 'amazon-product-in-a-post-plugin' ) . '
    ' . __( 'Split ASINs?', 'amazon-product-in-a-post-plugin' ) . '   ' . __( 'Check to make all ASINs individual posts/pages', 'amazon-product-in-a-post-plugin' ) . '
    ' . __( 'Post Content', 'amazon-product-in-a-post-plugin' ) . ':
    ' . __( 'Product Location', 'amazon-product-in-a-post-plugin' ) . ':    ' . __( 'Above Post Content - Default - Product will be first then post text', 'amazon-product-in-a-post-plugin' ) . '
       ' . __( 'Below Post Content - Post text will be first then the Product', 'amazon-product-in-a-post-plugin' ) . '
       ' . __( 'Post Text becomes Description - Post text will become part of the Product layout', 'amazon-product-in-a-post-plugin' ) . '
    ' . __( 'Additional Items', 'amazon-product-in-a-post-plugin' ) . ': ' . implode( "\n", $extrasec ) . '

    '; }