/** * */ private function _createDefaultButton() { $_iPostID = $this->createPost(AmazonAutoLinks_Registry::$aPostTypes['button'], array('post_title' => __('Default', 'amazon-auto-links')), array('button_label' => __('Buy Now', 'amazon-auto-links'))); if ($_iPostID) { update_post_meta($_iPostID, 'button_css', AmazonAutoLinks_ButtonStyleLoader::getDefaultButtonCSS($_iPostID)); } }
/** * * @scope public It is static public as unit class needs to retrieve the CSS rules to check the parsing button exists. * @return string */ public static function getButtonsCSS() { // Use cache if (isset(self::$sButtonsCSS)) { return self::$sButtonsCSS; } $_sCSSStored = get_option(AmazonAutoLinks_Registry::$aOptionKeys['button_css'], ''); if (!$_sCSSStored) { // Update the button CSS option. $_sCSSStored = self::getCSSRulesOfActiveButtons(); if ($_sCSSStored) { update_option(AmazonAutoLinks_Registry::$aOptionKeys['button_css'], $_sCSSStored); } } $_sCSSRules = apply_filters('aal_filter_button_css', self::getDefaultButtonCSS() . PHP_EOL . $_sCSSStored); // Cache for later use. self::$sButtonsCSS = $_sCSSRules; return self::$sButtonsCSS; }
/** * * @return string|integer The set button id. If not set, `default` will be returned. */ protected function _getButtonID() { $_iButtonID = $this->oUnitOption->get('button_id'); // Consider cases that options are deleted by external means. $_sCSS = AmazonAutoLinks_ButtonStyleLoader::getButtonsCSS(); if ($_iButtonID && false !== strpos($_sCSS, $_iButtonID)) { return $_iButtonID; } return 'default'; }