/** * Get singleton instance * @param array $globals Optional, only on first call */ public static function getInstance(array $globals = array()) { if (self::$instance === null) { self::$instance = new WPML(); // set globals foreach ($globals as $key => $value) { self::$instance->globals[$key] = $value; } self::$instance->init(); } return self::$instance; }
/** * WP action callback */ public function actionAdminMenu() { if ($this->settings['mainMenu']) { // create main menu item $pageHook = add_menu_page($this->settings['pageTitle'], $this->settings['pageTitle'], 'manage_options', $this->settings['pageKey'], array($this, 'showPage'), WPML::url($this->settings['menuIcon'])); } else { // create submenu item under "Settings" $pageHook = add_submenu_page('options-general.php', $this->settings['pageTitle'], $this->settings['pageTitle'], 'manage_options', $this->settings['pageKey'], array($this, 'showPage')); } // load plugin page add_action('load-' . $pageHook, array($this, 'loadPage')); }
/** * WP action callback * @return void */ public function actionAdminNotices() { if (!WPML::get('isCompatible')) { $plugin_title = get_admin_page_title(); echo '<div class="error">'; echo sprintf(WPML::__('<p>Error - The plugin <strong>%1$s</strong> requires PHP %2$s + and WP %3$s +.' . ' Please upgrade your PHP and/or WordPress.' . '<br/>Disable the plugin to remove this message.</p>'), $plugin_title, WPML::get('minPhpVersion'), WPML::get('minWpVersion')); echo '</div>'; } if (isset($_GET['page']) && $_GET['page'] === WPML::get('adminPage') && is_plugin_active('email-encoder-bundle/email-encoder-bundle.php')) { WPML_View::factory('/admin/notices.php')->show(); } }
/** * WP action callback */ public function actionInit() { WPML::set('optionValues', $this->initOptionValues()); if (is_admin()) { // create admin WPML::set('admin', new WPML_Admin()); } else { // create front WPML::set('front', new WPML_Front()); } // init test if (class_exists('Test_WP_Mailto_Links')) { $Test = new Test_WP_Mailto_Links(); } }
Add_Filter('glossary_available_prefix_filters', array(__CLASS__, 'filterAvailablePrefixFilters')); } static function IsWPMLActive() { return Defined('ICL_SITEPRESS_VERSION'); } static function filterGettextWithContext($translation, $text, $context, $domain) { # If you are using WPML the post type slug MUST NOT be translated! You can translate your slug in WPML if (self::IsWPMLActive() && $context == 'URL slug' && $domain == I18n::getTextDomain()) { return $text; } else { return $translation; } } static function filterAvailablePrefixFilters($arr_filter) { if (self::IsWPMLActive() && Is_Array($arr_filter)) { foreach ($arr_filter as $index => $filter) { # Check if there are posts behind this filter in this language $query = new \WP_Query(array('post_type' => Post_Type::$post_type_name, 'post_title_like' => $filter . '%', 'posts_per_page' => 1)); if (!$query->Have_Posts()) { unset($arr_filter[$index]); } } } return $arr_filter; } } WPML::Init();
function wpml_filter($content) { return WPML::get('front')->filterContent($content); }
</strong></p> </div> <?php } ?> <form method="post" action="options.php"> <?php settings_fields(WPML::get('key')); ?> <input type="hidden" name="<?php echo WPML::get('key'); ?> _nonce" value="<?php echo wp_create_nonce(WPML::get('key')); ?> " /> <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> <div id="poststuff"> <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?> "> <!--<div id="post-body-content"></div>-->
?> </th> <td><label><input type="checkbox" id="<?php echo WPML::get('optionName'); ?> [own_admin_menu]" name="<?php echo WPML::get('optionName'); ?> [own_admin_menu]" value="1" <?php checked('1', (int) $values['own_admin_menu']); ?> /> <span><?php WPML::_e('Show as main menu item'); ?> </span> <br/><span class="description"><?php WPML::_e('When disabled item will be shown under "General settings".'); ?> </span></label></td> </tr> </table> </fieldset> <p class="submit"> <input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes'); ?> " /> </p> <br class="clear" />
<h3><img src="<?php echo WPML::url('images/icon-wp-mailto-links.png'); ?> " width="16" height="16" /> <?php echo get_admin_page_title(); ?> - version <?php echo WPML::get('version'); ?> </h3> <p>Protect your email addresses and manage mailto links on your site, set mail icon, styling and more.</p> <h4>Features</h4> <ul> <li>Protect mailto links automatically</li> <li>Protect plain email addresses or convert them to mailto links</li> <li>Protect RSS feed</li> <li>Set mail icon</li> <li>Use shortcodes, template functions, action and filter hooks</li> </ul>
<?php defined('ABSPATH') or die('No direct access.'); /* Plugin Name: WP Mailto Links - Manage Email Links Plugin URI: http://www.freelancephp.net/wp-mailto-links-plugin Description: Manage mailto links on your site and protect email addresses from spambots, set mail icon and more. Author: Victor Villaverde Laan Version: 1.6.0 Author URI: http://www.freelancephp.net License: Dual licensed under the MIT and GPL licenses Text Domain: wp-mailto-links Domain Path: /languages */ define('WPML_VERSION', '1.6.0'); define('WPML_MIN_PHP_VERSION', '5.2.4'); define('WPML_MIN_WP_VERSION', '3.6'); // includes require_once dirname(__FILE__) . '/classes/WP/Plugin/Abstract.php'; require_once dirname(__FILE__) . '/classes/WPML.php'; // wp_version var was used by older WP versions if (!isset($wp_version)) { $wp_version = get_bloginfo('version'); } // compatibility $compatiblePhpVersion = version_compare(phpversion(), WPML_MIN_PHP_VERSION, '>='); $compatibleWpVersion = version_compare($wp_version, WPML_MIN_WP_VERSION, '>='); // init plugin WPML::getInstance(array('version' => WPML_VERSION, 'key' => 'WP_Mailto_Links', 'domain' => 'wp-mailto-links', 'optionName' => 'WP_Mailto_Links_options', 'adminPage' => 'wp-mailto-links-settings', 'file' => __FILE__, 'dir' => dirname(__FILE__), 'pluginUrl' => plugins_url('', __FILE__), 'wpVersion' => $wp_version, 'minPhpVersion' => WPML_MIN_PHP_VERSION, 'minWpVersion' => WPML_MIN_WP_VERSION, 'isCompatible' => $compatiblePhpVersion && $compatibleWpVersion));
</a> <?php } elseif (file_exists(WP_PLUGIN_DIR . '/email-encoder-bundle/email-encoder-bundle.php')) { ?> <a href="<?php echo get_bloginfo('url'); ?> /wp-admin/plugins.php?plugin_status=inactive"><?php WPML::_e('Activate'); ?> </a> <?php } else { ?> <a href="<?php echo get_bloginfo('url'); ?> /wp-admin/plugin-install.php?tab=search&type=term&s=WP+Mailto+Links+freelancephp&plugin-search-input=Search+Plugins"><?php WPML::_e('Get this plugin'); ?> </a> <?php } ?> </h4> <p><?php WPML::_e('Encode mailto links, email addresses or any text and hide them from spambots. Easy to use, plugin works directly when activated.'); ?> <br /><a href="http://wordpress.org/extend/plugins/email-encoder-bundle/" target="_blank">WordPress.org</a> | <a href="http://www.freelancephp.net/wp-email-encoder-bundle-plugin-3/" target="_blank">FreelancePHP.net</a> </p>
<ul> <li><a href="#" class="wpml-help-link"><?php WPML::_e('Documentation'); ?> </a></li> <li><a href="http://wordpress.org/support/plugin/wp-mailto-links#postform" target="_blank"><?php WPML::_e('Report a problem'); ?> </a></li> </ul> <p><strong><a href="http://wordpress.org/support/view/plugin-reviews/wp-mailto-links" target="_blank"><?php WPML::_e('Please rate this plugin!'); ?> </a></strong></p>
</td> </tr> <tr> <th><?php WPML::_e('Set protection text *'); ?> </th> <td><label><input type="text" id="protection_text" class="regular-text" name="<?php echo WPML::get('optionName'); ?> [protection_text]" value="<?php echo $values['protection_text']; ?> " /> <br/><span class="description"><?php WPML::_e('This text will be shown for protected emailaddresses.'); ?> </span> </label> </td> </tr> </table> </fieldset> <p class="submit"> <input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes'); ?> " /> </p> <br class="clear" />
</tr> <tr> <th><?php WPML::_e('Additional Classes (optional)'); ?> </th> <td><label><input type="text" class="regular-text" id="<?php echo WPML::get('optionName'); ?> [class_name]" name="<?php echo WPML::get('optionName'); ?> [class_name]" value="<?php echo $values['class_name']; ?> " /> <br/><span class="description"><?php WPML::_e('Add extra classes to mailto links (or leave blank).'); ?> </span></label></td> </tr> </table> </fieldset> <p class="submit"> <input class="button-primary" type="submit" disabled="disabled" value="<?php _e('Save Changes'); ?> " /> </p> <br class="clear" />