</tr> <tr> <th valign="top" scope="row"><label for="syc_description"><?php SyC::t('sdk', 'Description:'); ?> </label></th> <td><textarea name="syc_description" id="syc_description" class="regular-text" style="width:450px; height:200px;"><?php echo $description; ?> </textarea> <p class="howto"><?php echo SyC::t('sdk', 'Leave blank to use the main description'); ?> </p></td> </tr> <tr> <th valign="middle" scope="row"><?php echo SyC::t('sdk', 'Product Image:'); ?> </th> <td valign="middle"><p class="howto"><?php echo SyC::t('sdk', "Use wordpress' featured image functionality. You can find it on the right side."); ?> </p></td> </tr> </table> <input type="hidden" name="syc_nonce" id="syc_nonce" value="<?php echo wp_create_nonce($this->_PLUGIN_PATH); ?> " /> </div>
echo isset($_POST['email']) ? $_POST['email'] : $this->getAdminEmail(); ?> "/> </td> </tr> <tr> <td colspan="2"> <input class="buttonCheckbox" name="syc-terms-agreement" id="syc-terms-agreement" <?php if ($_SERVER['REQUEST_METHOD'] !== 'POST' || isset($_POST['syc-terms-agreement'])) { echo 'checked="checked"'; } ?> type="checkbox" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/create-view/toogle-terms-agreement-click']);"><label for="syc-terms-agreement"><?php echo SyC::t('sdk', 'I agree with the {brand} terms & conditions', array('{brand}' => '<a href="http://www.shareyourcart.com/terms" target="_blank" onclick=" if(_gaq) _gaq.push([\'_trackPageview\', \'/admin/create-view/logo-terms-click\']);">ShareYourCart</a>')); ?> </label> </td> </tr> <tr> <td colspan="2"> <input type="submit" name="syc-create-account" value="<?php echo SyC::t('sdk', 'Create account'); ?> " onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/create-view/save-click']);"/> </td> </tr> </table> <?php echo $html; ?> </form>
/** * * Create url for the specified file. The file must be specified in relative path * to the base of the plugin */ protected function createUrl($file) { //get the real file path $file = realpath($file); //calculate the relative path from this file $file = SyC::relativepath(dirname(__FILE__), $file); //append the relative path to the current file's URL return WP_PLUGIN_URL . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . $file; }
?app_key=<?php echo $this->getAppKey(); ?> &client_id=<?php echo $this->getClientId(); ?> &email=<?php echo $this->getAdminEmail(); ?> " class="button" target="_blank"><?php _e('Configure', 'woocommerce'); ?> </a> <p class="description"><?php echo SyC::t('sdk', 'You can choose how much of a discount to give (in fixed amount, percentage, or free shipping) and to which social media channels it should it be applied. You can also define what the advertisement should say, so that it fully benefits your sales.'); ?> </p> </td> </tr> <?php } ?> </table> <div class="submit"> <input type="submit" class="button button-primary" name="syc-account-form" value="<?php _e('Save changes', 'woocommerce'); ?>
//only show if a known shopping cart is active ?> <h3><?php echo SyC::t('sdk', 'Remarks'); ?> </h3> <p><?php echo SyC::t('sdk', 'If you want to use the {brand} button on a product\'s page, you need to <strong>append</strong> {product-property} to the {callback-url} value, where {product-property} is the product\'s id', array('{brand}' => '<a href="http://www.shareyourcart.com" target="_blank" title="Shareyourcart™" onclick=" if(_gaq) _gaq.push([\'_trackPageview\', \'/admin/documentation/logo-click\']);">ShareYourCart™</a>', '{product-property}' => '<code>&p=<product_id></code>', '{callback-url}' => '<strong>data-syc-callback_url</strong>')); ?> </p> <?php } ?> <?php if ($show_footer) { ?> <h2><?php echo SyC::t('sdk', 'Contact'); ?> </h2> <p><?php echo SyC::t('sdk', "If you've got 30 seconds, we'd {link-1} love to know what ideal outcome you'd like ShareYourCart to help bring to your business</a>, or if you have a private question, you can {link-2} contact us directly</a>", array('{link-1}' => '<a href="http://shareyourcart.uservoice.com" target="_blank" title="forum" class="api-link" onclick=" if(_gaq) _gaq.push([\'_trackPageview\', \'/admin/documentation/forum-click\']);">', '{link-2}' => '<a href="http://www.shareyourcart.com/contact" target="_blank" class="api-link" onclick=" if(_gaq) _gaq.push([\'_trackPageview\', \'/admin/documentation/contact-click\']);">')); ?> </p> <br /> <?php } ?> </div> </div>
/** * * Check the SDK status * @param $force. TRUE to check, no matter how soon the previous check was. This can have a great impact on the experience of the admin * */ protected function checkSDKStatus($force = false) { //call the API at most only once every 5 minutes, not sooner if (!$force && time() - $this->getConfigValue('api_last_check') < 5 * 60) { return; } //set the latest check time $this->setConfigValue('api_last_check', time()); //get an update from the API $message = ''; if (is_array($result = $this->getSDKStatus($this->getSecretKey(), $this->getClientId(), $this->getAppKey(), $message))) { //save the data $this->setConfigValue('api_version', @$result['api_version']); $this->setConfigValue('latest_version', @$result['plugin_latest_version']); $this->setConfigValue('download_url', @$result['plugin_download_url']); //set the current language the SDK should be displayed in if (isset($result['lang'])) { $this->setConfigValue('lang', $result['lang']); SyC::setLanguage($result['lang']); } } else { //simply log the error, for now! error_log(print_r($message, true)); } }
?> "/> </td> </tr> <tr> <td> <label for="email"><?php echo SyC::t('sdk', 'Email:'); ?> </label> </td> <td> <input type="text" name="email" id="email" class="regular-text" value="<?php echo isset($_POST['email']) ? $_POST['email'] : $this->getAdminEmail(); ?> "/> </td> </tr> <tr> <td colspan="2"> <input type="submit" name="syc-recover-account" value="<?php echo SyC::t('sdk', 'Recover my account'); ?> " onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/recover-view/save-click']);" /> </td> </tr> </table> <?php echo $html; ?> </form>
?> </span> </td> </tr> <tr> <th scope="row" valign="top"><?php echo SyC::t('sdk', 'Position cart button after: '); ?> </th> <td> <input name="cart_button_position" class="regular-text" value="<?php echo $this->getCartButtonPosition(); ?> " /> <span class="description"><?php echo SyC::t('sdk', '<strong>jQuery selector</strong>. Start with <strong>{elem}</strong> to position the button before the actual object', array('{elem}' => "/*before*/")); ?> </span> </td> </tr> </table> </fieldset> <div class="submit"> <input type="submit" class="button button-primary" name="syc-visual-form" value="<?php _e('Save changes', 'woocommerce'); ?> " /> </div> </div> </div>
public function couponCallback() { //since there are a lot of plugins for wordpress, first make sure this plugin //is active if (!$this->isCartActive()) { throw new Exception(SyC::t('sdk', 'Shopping Cart is not active')); } parent::couponCallback(); //since this is actually an API, exit exit; }
<?php if ($this->hasNewerVersion()) { //if there is a newer version, show the upgrade message ?> <div class="syc-update-nag"> <strong><?php echo SyC::t('sdk', '{link}ShareYourCart {version}</a> is available! {link}Please update now</a>.', array('{version}' => $this->getConfigValue('latest_version'), '{link}' => '<a href="' . $this->getConfigValue("download_url") . '" target="_blank">')); ?> </strong> </div> <?php }
/** * * Language loader ( from the DB ) * */ public function loadLanguage($lang, $category) { //see if we have the language saved in the db $messages = $this->getConfigValue('messages'); if (empty($messages)) { $messages = SyC::loadFileLanguage($lang, $category); } //make sure we have an array for this variable if (!is_array($messages)) { $messages = array(); } return $messages; }
/** * * change the language loader method * */ public static function setLanguageLoader($loader) { //make sure the loader is ok if (!is_callable($loader)) { throw new Exception(SyC::t('sdk', "The language loader is not a valid callback")); } self::$loadLanguage = $loader; //reset the old messages, so that they are reloaded with the new loader self::$_messages = null; }
public static function t($category, $message, $params = array()) { //load the translation from file if not done so if (!isset(self::$_messages)) { //The language is the folder name, and the category is the name of the file $messageFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'messages' . DIRECTORY_SEPARATOR . self::$_language . DIRECTORY_SEPARATOR . $category . '.php'; if (is_file($messageFile)) { self::$_messages = (include $messageFile); } //make sure we have an array for this variable if (!is_array(self::$_messages)) { self::$_messages = array(); } } //check if the text has a valid translation if (isset(self::$_messages[$message]) && !empty(self::$_messages[$message])) { $message = self::$_messages[$message]; } //return the translated message, with the parameters replaced return $params !== array() ? strtr($message, $params) : $message; }