public function getOutput() { // Retrieve IDs $_aIDs = array(); // The id parameter - the id parameter can accept comma delimited ids. if (isset($this->aArgs['id'])) { if (is_string($this->aArgs['id']) || is_integer($this->aArgs['id'])) { $_aIDs = array_merge(AmazonAutoLinks_Utilities::convertStringToArray($this->aArgs['id'], ","), $_aIDs); } else { if (is_array($this->aArgs['id'])) { $_aIDs = $this->aArgs['id']; // The Auto-insert feature passes the id as array. } } } // The label parameter. if (isset($this->aArgs['label'])) { $this->aArgs['_labels'] = AmazonAutoLinks_Utilities::convertStringToArray($this->aArgs['label'], ","); $_aIDs = array_merge($this->_getPostIDsByLabel($this->aArgs['_labels'], isset($arrArgs['operator']) ? $arrArgs['operator'] : null), $_aIDs); } $_aOutputs = array(); $_aIDs = array_unique($_aIDs); foreach ($_aIDs as $_iID) { $_aOutputs[] = $this->_getOutputByID($_iID); } return implode('', $_aOutputs); }
/** * @param array The argument array/ * @param null This is only to be compatible with the parent class method. */ protected function getRSSURLsFromArguments($arrArgs, $_deprecated = null) { $arrRSSURLs = array(); $strScheme = $this->fIsSSL ? 'https' : 'http'; $arrTags = AmazonAutoLinks_Utilities::convertStringToArray($arrArgs['tags'], ","); // If the customer ID is provided, compose the URL for it first. if ($arrArgs['customer_id']) { if (!$arrArgs['tags'] || empty($arrTags)) { $arrRSSURLs[] = "{$strScheme}://www.amazon.com/rss/people/{$arrArgs['customer_id']}/products?tag={$arrArgs['associate_id']}"; return $arrRSSURLs; } foreach ($arrTags as $strTag) { $strTag = strtolower($strTag); $arrRSSURLs[] = "{$strScheme}://www.amazon.com/rss/people/{$arrArgs['customer_id']}/products/{$strTag}?tag={$arrArgs['associate_id']}&threshold={$arrArgs['threshold']}"; } return $arrRSSURLs; } // So there is a tag set by the user. foreach ($arrTags as $strTag) { $strTag = strtolower($strTag); foreach ($arrArgs['feed_type'] as $strType => $fEnable) { if (!$fEnable) { continue; } // $strType : new, popular, or recent $arrRSSURLs[] = "{$strScheme}://www.amazon.com/rss/tag/{$strTag}/{$strType}?tag={$arrArgs['associate_id']}&threshold={$arrArgs['threshold']}"; } } // AmazonAutoLinks_Debug::logArray( $arrRSSURLs ); return $arrRSSURLs; }
/** * Sets up black and white lists property array from the stored option values. * */ protected function setBlackWhiteLists() { $arrBlackWhiteLists = array(); foreach ($this->oOption->arrOptions['aal_settings']['product_filters'] as $strSection => $arrSection) { if ($strSection == 'case_sensitive') { $this->fBWListCaseSensitive = $arrSection; continue; } if ($strSection == 'no_duplicate') { $this->fNoDuplicate = $arrSection; continue; } if (is_array($arrSection)) { foreach ($arrSection as $strArea => $strUserInput) { $arrBlackWhiteLists[$strSection][$strArea] = AmazonAutoLinks_Utilities::convertStringToArray($strUserInput, ','); } } } $this->arrBlackListASINs = $arrBlackWhiteLists['black_list']['asin']; $this->arrBlackListTitles = $arrBlackWhiteLists['black_list']['title']; $this->arrBlackListDescriptions = $arrBlackWhiteLists['black_list']['description']; $this->arrWhiteListASINs = $arrBlackWhiteLists['white_list']['asin']; $this->arrWhiteListTitles = $arrBlackWhiteLists['white_list']['title']; $this->arrWhiteListDescriptions = $arrBlackWhiteLists['white_list']['description']; }
public function __construct($sOptionKey) { $this->strOptionKey = $sOptionKey; $this->arrOptions = $this->set($sOptionKey); $this->strCharEncoding = get_bloginfo('charset'); // Black ASINs $GLOBALS['arrBlackASINs'] = AmazonAutoLinks_Utilities::convertStringToArray($this->arrOptions['aal_settings']['product_filters']['black_list']['asin'], ','); }
public function validation_AmazonAutoLinks_MetaBox_Template($arrInput, $arrOldInput) { // validation_ + extended class name // Apply allowed HTML tags for the KSES filter. add_filter('safe_style_css', array($this, 'allowInlineStyleMaxWidth')); $arrAllowedHTMLTags = AmazonAutoLinks_Utilities::convertStringToArray($GLOBALS['oAmazonAutoLinks_Option']->arrOptions['aal_settings']['form_options']['allowed_html_tags'], ','); $arrInput['item_format'] = AmazonAutoLinks_WPUtilities::escapeKSESFilter($arrInput['item_format'], $arrAllowedHTMLTags); $arrInput['image_format'] = AmazonAutoLinks_WPUtilities::escapeKSESFilter($arrInput['image_format'], $arrAllowedHTMLTags); $arrInput['title_format'] = AmazonAutoLinks_WPUtilities::escapeKSESFilter($arrInput['title_format'], $arrAllowedHTMLTags); remove_filter('safe_style_css', array($this, 'allowInlineStyleMaxWidth')); return $arrInput; }
public function validation_aal_add_tag_unit($arrInput, $arrOldInput) { // validation + _ + page slug + tab slug $fVerified = true; $arrErrors = array(); // Check the limitation. if ($this->oOption->isUnitLimitReached()) { $this->setSettingNotice(sprintf(__('Please upgrade to <A href="%1$s">Pro</a> to add more units! Make sure to empty the <a href="%2$s">trash box</a> to delete the units completely!', 'amazon-auto-links'), 'http://en.michaeluno.jp/amazon-auto-links-pro/', admin_url('edit.php?post_status=trash&post_type=' . AmazonAutoLinks_Commons::PostTypeSlug))); return $arrOldInput; } // Customer ID must be 13 characters if ($arrInput['aal_add_tag_unit']['tag']['tag_customer_id'] && strlen($arrInput['aal_add_tag_unit']['tag']['tag_customer_id']) != 13) { $arrErrors['tag']['tag_customer_id'] = __('The customer ID must consist of 13 characters.', 'amazon-auto-links') . ' '; $arrInput['aal_add_tag_unit']['tag']['tag_customer_id'] = ''; $fVerified = false; } if (empty($arrInput['aal_add_tag_unit']['tag']['tag_tags']) && empty($arrInput['aal_add_tag_unit']['tag']['tag_customer_id'])) { $arrErrors['tag']['tag_tags'] = __('Either tags or customer ID has to be entered.', 'amazon-auto-links'); $strMessage = __('Either tags or customer ID has to be entered.', 'amazon-auto-links'); $arrErrors['tag']['tag_customer_id'] = isset($arrErrors['tag']['tag_customer_id']) ? $arrErrors['tag']['tag_customer_id'] . $strMessage : $strMessage; $fVerified = false; } if (empty($arrInput['aal_add_tag_unit']['tag']['tag_associate_id'])) { $arrErrors['tag']['tag_associate_id'] = __('The associate ID cannot be empty.', 'amazon-auto-links'); $fVerified = false; } // An invalid value is found. if (!$fVerified) { // Set the error array for the input fields. $this->setFieldErrors($arrErrors); $this->setSettingNotice(__('There was an error in your input.', 'amazon-auto-links')); return $arrOldInput; } // Drop the sections. $arrNewFields = array(); foreach ($arrInput['aal_add_tag_unit'] as $strSection => $arrFields) { $arrNewFields = $arrNewFields + $arrFields; } $arrSanitizedFields = array(); // Remove the tag_ prefix in the keys. foreach ($arrNewFields as $strKey => $vValue) { $arrSanitizedFields[preg_replace('/^tag_/', '', $strKey)] = $vValue; } // Sanitize the tag input $arrSanitizedFields['tags'] = trim(AmazonAutoLinks_Utilities::trimDelimitedElements($arrSanitizedFields['tags'], ',')); $arrSanitizedFields = $this->oOption->sanitizeUnitOpitons($arrSanitizedFields); // If nothing is checked for the feed type, enable the bestseller item. if (!array_filter($arrSanitizedFields['feed_type'])) { $arrSanitizedFields['feed_type']['new'] = true; } // AmazonAutoLinks_Debug::logArray( '--Before Escaping KSES Filter--' ); // AmazonAutoLinks_Debug::logArray( $arrSanitizedFields['item_format'] ); // AmazonAutoLinks_Debug::logArray( $arrSanitizedFields['image_format'] ); // AmazonAutoLinks_Debug::logArray( $arrSanitizedFields['title_format'] ); // Apply allowed HTML tags for the KSES filter. add_filter('safe_style_css', array($this, 'allowInlineStyleMaxWidth')); $arrAllowedHTMLTags = AmazonAutoLinks_Utilities::convertStringToArray($this->oOption->arrOptions['aal_settings']['form_options']['allowed_html_tags'], ','); $arrSanitizedFields['item_format'] = AmazonAutoLinks_WPUtilities::escapeKSESFilter($arrSanitizedFields['item_format'], $arrAllowedHTMLTags); $arrSanitizedFields['image_format'] = AmazonAutoLinks_WPUtilities::escapeKSESFilter($arrSanitizedFields['image_format'], $arrAllowedHTMLTags); $arrSanitizedFields['title_format'] = AmazonAutoLinks_WPUtilities::escapeKSESFilter($arrSanitizedFields['title_format'], $arrAllowedHTMLTags); remove_filter('safe_style_css', array($this, 'allowInlineStyleMaxWidth')); // AmazonAutoLinks_Debug::logArray( '--After Escaping KSES Filter--' ); // AmazonAutoLinks_Debug::logArray( $arrAllowedHTMLTags ); // AmazonAutoLinks_Debug::logArray( $arrSanitizedFields['item_format'] ); // AmazonAutoLinks_Debug::logArray( $arrSanitizedFields['image_format'] ); // AmazonAutoLinks_Debug::logArray( $arrSanitizedFields['title_format'] ); // Create a post. $fDoAutoInsert = $arrSanitizedFields['auto_insert']; unset($arrSanitizedFields['auto_insert']); $intNewPostID = AmazonAutoLinks_Option::insertPost($arrSanitizedFields); // Create an auto insert if ($fDoAutoInsert) { $arrAutoInsertOptions = array('unit_ids' => array($intNewPostID)) + AmazonAutoLinks_Form_AutoInsert::$arrStructure_AutoInsertOptions; AmazonAutoLinks_Option::insertPost($arrAutoInsertOptions, AmazonAutoLinks_Commons::PostTypeSlugAutoInsert); } die(wp_redirect(add_query_arg(array('post_type' => AmazonAutoLinks_Commons::PostTypeSlug, 'action' => 'edit', 'post' => $intNewPostID), admin_url('post.php')))); }
public function cell_aal_auto_insert_area($strCell, $intPostID) { $arrList = array(); $arrSelectedAreas = (array) get_post_meta($intPostID, 'built_in_areas', true) + (array) get_post_meta($intPostID, 'static_areas', true); $arrSelectedAreas = array_filter($arrSelectedAreas); $arrAreasLabel = AmazonAutoLinks_Form_AutoInsert::getPredefinedFilters() + AmazonAutoLinks_Form_AutoInsert::getPredefinedFiltersForStatic(false); foreach ($arrSelectedAreas as $strArea => $fEnable) { if (isset($arrAreasLabel[$strArea])) { $arrList[] = $arrAreasLabel[$strArea]; } } $arrFilters = AmazonAutoLinks_Utilities::convertStringToArray(get_post_meta($intPostID, 'filter_hooks', true), ','); $arrActions = AmazonAutoLinks_Utilities::convertStringToArray(get_post_meta($intPostID, 'action_hooks', true), ','); $arrList = array_merge($arrFilters, $arrActions, $arrList); return '<p>' . implode(', ', $arrList) . '</p>'; }
/** * Creates an array storing the auto-insert definition(post) ids with the keys of hooks. * * @param string $strOptionKey either 'filter_hooks' or 'action_hooks' which are defined in the AmazonAutoLinks_Form_AutoInsert class. */ protected function getHooks($arrAutoInsertOptions, $strOptionKey, $arrHooks = array()) { foreach ($arrAutoInsertOptions as $intAutoInsertID => $arrOptions) { $arrParsedHooks = AmazonAutoLinks_Utilities::convertStringToArray($arrOptions[$strOptionKey], ','); $arrParsedHooks = array_filter($arrParsedHooks); // drop non-values. foreach ($arrParsedHooks as $strHook) { $arrHooks[$strHook] = isset($arrHooks[$strHook]) && is_array($arrHooks[$strHook]) ? array_merge($arrHooks[$strHook], array($intAutoInsertID)) : array($intAutoInsertID); } } foreach ($arrHooks as &$arrIDs) { $arrIDs = array_unique(array_filter($arrIDs)); if (empty($arrIDs)) { unset($arrIDs); } } return $arrHooks; }