/** * Prints out the fetched product links. * * @remark Used for the post type single page that functions as preview the result. * */ public function _replytToPrintPreviewProductLinks($sContent) { if (!is_singular()) { return $sContent; } if (!isset($GLOBALS['post']->post_type) || $GLOBALS['post']->post_type != $this->oProps->strPostType) { return $sContent; } if (!$GLOBALS['oAmazonAutoLinks_Option']->isPreviewVisible()) { return $sContent; } $_aUnitOptions = AmazonAutoLinks_Option::getUnitOptionsByPostID($GLOBALS['post']->ID); $_aUnitOptions['id'] = $GLOBALS['post']->ID; return $sContent . AmazonAutoLinks_Units::getInstance($_aUnitOptions)->getOutput(); }
function AmazonAutoLinks($aArgs) { return AmazonAutoLinks_Units::getInstance($aArgs)->render(); }
/** * Handles static insertion for posts. * * @remark Only category taxonomy allow/deny check is supported. Other types post_tags and custom taxonomies are not supported yet. */ public function doFilterForStaticInsertion($arrPostContent, $arrPostMeta = array()) { // if the publish key exists, it means it is an update if (isset($arrPostMeta['save']) && $arrPostMeta['save'] == 'Update') { return $arrPostContent; } // If it's auto-draft saving feature, do nothing. if (isset($arrPostContent['post_status']) && $arrPostContent['post_status'] != 'publish') { return $arrPostContent; } // The default disabled post types. if (in_array($arrPostContent['post_type'], array(AmazonAutoLinks_Commons::PostTypeSlug, AmazonAutoLinks_Commons::PostTypeSlugAutoInsert, 'revision', 'attachment', 'nav_menu_item'))) { return $arrPostContent; } /* $arrPostMeta structure [ID] => 278 [post_category] => Array ( [0] => 0 [1] => 10 [2] => 9 [3] => 1 ) [tax_input] => Array( [post_tag] => test ) */ $arrSubjectPostInfo = array('post_id' => $arrPostMeta['ID'], 'post_type' => $arrPostContent['post_type'], 'term_ids' => $arrPostMeta['post_category']) + self::$arrStructure_SubjectPageInfo; $strPre = ''; $strPost = ''; foreach ($this->arrFilterHooks['wp_insert_post_data'] as $intAutoInsertID) { if (!$this->isAutoInsertEnabledPage($intAutoInsertID, $arrSubjectPostInfo)) { continue; } $arrAutoInsertOptions = $this->arrAutoInsertOptions[$intAutoInsertID]; // position - above, below, or both, $strPosition = $arrAutoInsertOptions['static_position']; if ($strPosition == 'above' || $strPosition == 'both') { $oUnits = new AmazonAutoLinks_Units(array('id' => $arrAutoInsertOptions['unit_ids'])); $strPre .= $oUnits->getOutput(); } if ($strPosition == 'below' || $strPosition == 'both') { $oUnits = new AmazonAutoLinks_Units(array('id' => $arrAutoInsertOptions['unit_ids'])); $strPost .= $oUnits->getOutput(); } } $arrPostContent['post_content'] = $strPre . $arrPostContent['post_content'] . $strPost; return $arrPostContent; }
/** * Returns the output based on the shortcode arguments. * * @since 2.0.0 * @since 2.1.1 Chagned the name from `getOutput()`. */ public function _replyToGetOutput($aArgs) { return AmazonAutoLinks_Units::getInstance($aArgs)->getOutput(); }