ID, 'aw_affiliatewire_quick_ignition_Landing_Page_value', true));
$download_link = (aw_get_metadata('post', $post->ID, 'aw_affiliatewire_quick_ignition_Direct_Download_value', true));
$purchase_page = (aw_get_metadata('post', $post->ID, 'aw_affiliatewire_quick_ignition_Purchase_Page_value', true));
$product_box = (aw_get_metadata('post', $post->ID, 'aw_affiliatewire_quick_ignition_Product_Box_value', true));
$product_name = (aw_get_metadata('post', $post->ID, 'aw_affiliatewire_quick_ignition_Product_Name_value', true));
$product_description = (aw_get_metadata('post', $post->ID, 'aw_affiliatewire_quick_ignition_Product_Description_value', true));
$product_details = (aw_get_metadata('post', $post->ID, 'aw_affiliatewire_quick_ignition_Product_Details_value', true));
$product_price = (aw_get_metadata('post', $post->ID, 'aw_affiliatewire_quick_ignition_Product_Price_value', true));
$content = aw_affiliatewire_quick_ignition_replace_placeholder_codes_text(awItems::awDescription, '', $product_description, $content);
$content = aw_affiliatewire_quick_ignition_replace_placeholder_codes_text(awItems::awProductName, '', $product_name, $content);
$content = aw_affiliatewire_quick_ignition_replace_placeholder_codes_text(awItems::awProductPrice, '', $product_price, $content);
$content = aw_affiliatewire_quick_ignition_replace_placeholder_codes_image(awItems::awProductBox, $product_name, $product_box, $content);
$content = aw_affiliatewire_quick_ignition_replace_placeholder_codes_links(awItems::awLandingPage, 'More Information', $landing_page, $content);
$content = aw_affiliatewire_quick_ignition_replace_placeholder_codes_links(awItems::awBuyNow, 'Buy Now', $purchase_page, $content);
$content = aw_affiliatewire_quick_ignition_replace_placeholder_codes_links(awItems::awDownload, 'Download', $download_link, $content);
$content = aw_affiliatewire_quick_ignition_add_class_to_links($content, 'post' . $post->ID, true);
global $pagenow;
if ($pagenow == 'index.php') {
$content .= aw_affiliatewire_quick_ignition_getCSS();
}
return $content;
}
function aw_affiliatewire_quick_ignition_replace_placeholder_codes_links($idName, $message, $link, $text) {
//replace text with link with text based on text found between the tags
//if no text is found use the default message
$pattern = '/[[]' . $idName . '([^]]*)[]](.*)[[][\/]' . $idName . '[]]/i';
$count = preg_match_all($pattern, $text, $matches);
for ($cnt = 0; $cnt < $count; $cnt++) {
$matchedText = trim(str_replace(' ', ' ', htmlentities(utf8_decode(strip_tags($matches[2][$cnt])))));
$matchedText2 = $matches[2][$cnt];
if ($matchedText == '') {
$matchedText = $message;
$matchedText2 = $message;
}
$replace = '' .
($matchedText2) . '';
$replace = aw_affiliatewire_quick_ignition_add_class_to_links($replace, $idName, false);
$text = str_replace($matches[0][$cnt], $replace, $text);
}
return $text;
}
function aw_affiliatewire_quick_ignition_replace_placeholder_codes_image($idName, $message, $link, $text) {
//replace text with link with text based on text found between the tags
//if no text is found use the default message
$pattern = '/[[]' . $idName . '([^]]*)[]](.*)[[][\/]' . $idName . '[]]/i';
$count = preg_match_all($pattern, $text, $matches);
for ($cnt = 0; $cnt < $count; $cnt++) {
$matchedText = trim(str_replace(' ', ' ', htmlentities(utf8_decode(strip_tags($matches[2][$cnt])))));
if ($matchedText == '') {
$matchedText = $message;
}
$replace = '';
$replace = aw_affiliatewire_quick_ignition_add_class_to_images($replace, $idName, false);
$text = str_replace($matches[0][$cnt], $replace, $text);
}
return $text;
}
function aw_affiliatewire_quick_ignition_replace_placeholder_codes_text($idName, $message, $link, $text) {
//replace text with link with text based on text found between the tags
//if no text is found use the default message
$pattern = '/[[]' . $idName . '([^]]*)[]](.*)[[][\/]' . $idName . '[]]/i';
$count = preg_match_all($pattern, $text, $matches);
for ($cnt = 0; $cnt < $count; $cnt++) {
$matchedText = trim(str_replace(' ', ' ', htmlentities(utf8_decode(strip_tags($matches[2][$cnt])))));
if ($matchedText == '') {
$matchedText = $message;
}
$replace = '' .
($link) . '';
$replace = aw_affiliatewire_quick_ignition_add_class_to_text($replace, $idName, false);
$text = str_replace($matches[0][$cnt], $replace, $text);
}
return $text;
}
global $aw_affiliatewire_quick_ignition_blank_meta_boxes;
$aw_affiliatewire_quick_ignition_blank_meta_boxes = aw_affiliatewire_quick_ignition_create_meta_boxes();
function aw_affiliatewire_quick_ignition_create_meta_boxes() {
//define basic metaboxes for storing data used by the plugin
$offerDetails = aw_affiliatewire_quick_ignition_getOptionArray($post);
$affiliateAliases = get_option('aw_affiliatewire_quick_ignition_affiliateAliases');
$toReturn =
array(
"Affiliate_Alias" => array(
"name" => "aw_affiliatewire_quick_ignition_Affiliate_Alias",
"std" => "",
"title" => "Affiliate Alias",
"type" => 'select',
"selectValues" => $affiliateAliases,
"description" => "Choose an aliases.",
"javascript" => aw_affiliatewire_quick_ignition_get_javascript(5),
"button" => ""),
"Product_Name" => array(
"name" => "aw_affiliatewire_quick_ignition_Product_Name",
"std" => "",
"title" => "
Product Name",
"description" => "Select a product using the drop-down menu or enter the name manually.
",
"chocies" => $offerDetails['products'],
"javascript" => aw_affiliatewire_quick_ignition_get_javascript(3),
"button" => ""),
"Landing_Page" => array(
"name" => "aw_affiliatewire_quick_ignition_Landing_Page",
"std" => "",
"title" => "Landing Page",
"description" => "Select a pre-made landing page using the drop-down menu or enter your own landing page URL.
",
"chocies" => "",
"javascript" => aw_affiliatewire_quick_ignition_get_javascript(1),
"button" => ''),
"Purchase_Page" => array(
"name" => "aw_affiliatewire_quick_ignition_Purchase_Page",
"std" => "",
"title" => "Purchase Page",
"description" => "",
"button" => ''),
"Direct_Download" => array(
"name" => "aw_affiliatewire_quick_ignition_Direct_Download",
"std" => "",
"title" => "
Direct Download Link",
"description" => "",
"button" => ''),
"Product_Price" => array(
"name" => "aw_affiliatewire_quick_ignition_Product_Price",
"std" => "",
"title" => "
Product Price",
"description" => "Select the product price or enter your own text.
",
"chocies" => "",
"javascript" => aw_affiliatewire_quick_ignition_get_javascript(2),
"button" => ""),
"Product_Box" => array(
"name" => "aw_affiliatewire_quick_ignition_Product_Box",
"std" => "",
"title" => "Product Box
",
"description" => "Use the default box shot shown or enter a custom image URL.",
"button" => ""),
"Product_Description" => array(
"name" => "aw_affiliatewire_quick_ignition_Product_Description",
"std" => "",
"title" => "
Product Description",
"type" => 'textarea',
"description" => "",
"button" => ""),
"Product_Details" => array(
"name" => "aw_affiliatewire_quick_ignition_Product_Details",
"std" => "",
"title" => "Product Details",
"type" => 'textarea',
"description" => "Add a detailed description of the product here.",
"button" => ""),
"Product_Images" => array(
"name" => "aw_affiliatewire_quick_ignition_Product_Images",
"std" => "",
"title" => "Product Images ",
"description" => "Choose from the available images and copy the url to insert into your post.
",
"chocies" => "",
"javascript" => aw_affiliatewire_quick_ignition_get_javascript(4))
);
unset($toReturn['Product_Details']);
return $toReturn;
}
function aw_affiliatewire_quick_ignition_new_meta_boxes() {
//create the meta boxes when the post page is created
global $post, $aw_affiliatewire_quick_ignition_blank_meta_boxes;
//populate the select dropdowns with information based on
//stored data with the post
$offerDetails = aw_affiliatewire_quick_ignition_getOptionArray($post->ID);
$aw_affiliatewire_quick_ignition_blank_meta_boxes['Landing_Page']["choices"] .= $offerDetails['landing_pages'];
$aw_affiliatewire_quick_ignition_blank_meta_boxes['Landing_Page']["javascript"] = aw_affiliatewire_quick_ignition_get_javascript(1);
$aw_affiliatewire_quick_ignition_blank_meta_boxes['Product_Price']["choices"] = $offerDetails['prices'];
$aw_affiliatewire_quick_ignition_blank_meta_boxes['Product_Price']['javascript'] = aw_affiliatewire_quick_ignition_get_javascript(2);
$aw_affiliatewire_quick_ignition_blank_meta_boxes['Product_Name']['choices'] = $offerDetails['products'];
$aw_affiliatewire_quick_ignition_blank_meta_boxes['Product_Name']['javascript'] = aw_affiliatewire_quick_ignition_get_javascript(3);
$aw_affiliatewire_quick_ignition_blank_meta_boxes['Product_Images']["choices"] = $offerDetails['product_images'];
$aw_affiliatewire_quick_ignition_blank_meta_boxes['Product_Images']["javascript"] = aw_affiliatewire_quick_ignition_get_javascript(4);
$aw_affiliatewire_quick_ignition_blank_meta_boxes['Affiliate_Alias']['defaultValue'] = aw_get_metadata('post', $post->ID, 'aw_affiliatewire_quick_ignition_Affiliate_Alias_value', true);
$meta_box_value = aw_get_metadata('post', $post->ID, 'aw_affiliatewire_quick_ignition_Product_Box' . '_value', true);
$aw_affiliatewire_quick_ignition_blank_meta_boxes['Product_Box']['title'] = "Product Box
";
//load the data into the meta boxes from the database
//and create the html to display it
foreach ($aw_affiliatewire_quick_ignition_blank_meta_boxes as $meta_box_name => $meta_box) {
$meta_box_value = aw_get_metadata('post', $post->ID, $meta_box['name'] . '_value', true);
if ($meta_box_value == "")
$meta_box_value = $meta_box['std'];
echo'';
echo'
' . $meta_box['choices'] . '
'; if (isset($meta_box['type']) && $meta_box['type'] == 'textarea') { echo ' Product Name |
Product Description |
Product Box Image |
Product Price |
Product Landing Page |
Product Buy Now |
Product Download Link |
' . wordwrap(print_r($cat, true), 150, "\n") . ''; } } if (!function_exists('get_site_url')) { /** * Retrieve the site url for a given site. * * Returns the 'site_url' option with the appropriate protocol, 'https' if * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is * overridden. * * @package WordPress * @since 3.0.0 * * @param int $blog_id (optional) Blog ID. Defaults to current blog. * @param string $path Optional. Path relative to the site url. * @param string $scheme Optional. Scheme to give the site url context. Currently 'http','https', 'login', 'login_post', or 'admin'. * @return string Site url link with optional path appended. */ function get_site_url($blog_id = null, $path = '', $scheme = null) { // should the list of allowed schemes be maintained elsewhere? $orig_scheme = $scheme; if (!in_array($scheme, array('http', 'https'))) { if (( 'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() )) $scheme = 'https'; elseif (( 'login' == $scheme ) && force_ssl_admin()) $scheme = 'https'; elseif (( 'admin' == $scheme ) && force_ssl_admin()) $scheme = 'https'; else $scheme = ( is_ssl() ? 'https' : 'http' ); } if (empty($blog_id) || !is_multisite()) $url = get_option('siteurl'); else $url = get_blog_option($blog_id, 'siteurl'); if ('http' != $scheme) $url = str_replace('http://', "{$scheme}://", $url); if (!empty($path) && is_string($path) && strpos($path, '..') === false) $url .= '/' . ltrim($path, '/'); return apply_filters('site_url', $url, $path, $orig_scheme, $blog_id); } } function aw_affiliatewire_quick_ignition_add_class_to_links($string, $class_name = 'awpost', $alwaysAdd = true) { $toReturn = $string; $matchString = '/([<][a][^>]*[>])/i'; $matchCount = preg_match_all($matchString, $toReturn, $matches); if (is_array($matches)) { foreach ($matches[0] as $match) { if (substr_count($match, 'class')) { if ($alwaysAdd == true) { $pos = strpos($match, 'class') + 7; $replacement = substr($match, 0, $pos) . $class_name . ' ' . substr($match, $pos); $toReturn = str_replace($match, $replacement, $toReturn); } } else { $replacement = str_replace(']*[>])/i'; $matchCount = preg_match_all($matchString, $toReturn, $matches); if (is_array($matches)) { foreach ($matches[0] as $match) { if (substr_count($match, 'class')) { if ($alwaysAdd == true) { $pos = strpos($match, 'class') + 7; $replacement = substr($match, 0, $pos) . $class_name . ' ' . substr($match, $pos); $toReturn = str_replace($match, $replacement, $toReturn); } } else { $replacement = str_replace('