本文整理汇总了PHP中SWP函数的典型用法代码示例。如果您正苦于以下问题:PHP SWP函数的具体用法?PHP SWP怎么用?PHP SWP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SWP函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: settings_license_nag
function settings_license_nag()
{
$nag = $this->implement_nag(array('name' => 'license', 'nonce' => 'searchwpnagnnonce'));
$searchwp = SWP();
$notices = searchwp_get_setting('notices');
$initial_notified = is_array($notices) && in_array('initial', $notices) ? true : false;
if (false == $initial_notified && !empty($searchwp->license) && (isset($searchwp->status) && 'valid' !== $searchwp->status) && !$nag['dismissed'] && apply_filters('searchwp_initial_license_nag', true)) {
?>
<div id="setting-error-settings_updated" class="updated settings-error swp-license-nag">
<p><?php
_e('In order to receive updates and support, you must have an active license.', 'searchwp');
?>
<a href="<?php
echo esc_url(add_query_arg(array('page' => 'searchwp', 'tab' => 'license'), admin_url('options.php')));
?>
"><?php
_e('Manage License', 'searchwp');
?>
</a> <a href="<?php
echo esc_url(SEARCHWP_EDD_STORE_URL);
?>
"><?php
_e('Purchase License', 'searchwp');
?>
</a> <a href="<?php
echo esc_url($nag['dismissal_link']);
?>
"><?php
_e('Dismiss', 'searchwp');
?>
</a></p>
</div>
<?php
}
}
示例2: log_file_size_warning
/**
* If the debug log is over 2MB
*/
function log_file_size_warning()
{
$searchwp = SWP();
$logfile = trailingslashit($searchwp->dir) . 'debug.log';
// if the logfile is over a 2MB it's likely the developer forgot to disable debugging
if (file_exists($logfile) && absint(filesize($logfile)) > 2097151) {
?>
<div class="error" id="searchwp-log-file-size">
<p><?php
_e('Your SearchWP debug log is quite large. Please remember to disable debugging and delete <code>~/wp-content/plugins/searchwp/debug.log</code> when you are done.', 'searchwp');
?>
</p>
</div>
<?php
}
}
示例3: prime_extensions
/**
* Perform initial Extension setup
*
* @since 1.3.1
*/
function prime_extensions()
{
$searchwp = SWP();
// implement extensions
$this->extensions = apply_filters('searchwp_extensions', array());
if (is_array($this->extensions) && !empty($this->extensions)) {
foreach ($this->extensions as $extension => $path) {
$class_name = 'SearchWP' . $extension;
if (!class_exists($class_name) && file_exists($path)) {
/** @noinspection PhpIncludeInspection */
include_once $path;
}
$this->extensions[$extension] = new $class_name($this);
// add plugin row action
if (isset($this->extensions[$extension]->min_searchwp_version) && version_compare($searchwp->version, $this->extensions[$extension]->min_searchwp_version, '<')) {
do_action('searchwp_log', 'after_plugin_row_' . plugin_basename($path));
add_action('after_plugin_row_' . plugin_basename($path), array($this, 'plugin_row'), 11, 3);
}
}
}
}
示例4: SWP
<?php
// exit if accessed directly
if (!defined('ABSPATH')) {
exit;
}
if (!current_user_can(apply_filters('searchwp_settings_cap', 'manage_options'))) {
die;
}
$searchwp = SWP();
?>
<div class="postbox swp-meta-box swp-default-engine metabox-holder swp-jqueryui">
<?php
$the_link = admin_url('index.php?page=searchwp-stats') . '&tab=default';
?>
<h3 class="hndle"><span><?php
_e('Default Search Engine', 'searchwp');
?>
</span> <a class="swp-engine-stats" href="<?php
echo esc_url($the_link);
?>
"><?php
_e('Statistics', 'searchwp');
?>
»</a></h3>
<div class="inside">
<p><?php
示例5: __construct
function __construct()
{
$this->searchwp = SWP();
}
示例6: plugin_row
function plugin_row()
{
if (!class_exists('SearchWP')) {
return;
}
$searchwp = SWP();
if (version_compare($searchwp->version, '2.0.3', '<')) {
?>
<tr class="plugin-update-tr searchwp">
<td colspan="3" class="plugin-update">
<div class="update-message">
<?php
_e('SearchWP LIKE Terms requires SearchWP 2.0.3 or greater', 'searchwp');
?>
</div>
</td>
</tr>
<?php
}
}
示例7: SWP
<?php
if ( ! defined( 'ABSPATH' ) ) {
die();
}
$parent = SWP();
$parent->define_keys();
$lazy_settings = apply_filters( 'searchwp_lazy_settings', false );
// progress of indexer
$remainingPostsToIndex = searchwp_get_setting( 'remaining', 'stats' );
$progress = searchwp_get_option( 'progress' );
if ( ! $parent->is_using_alternate_indexer() && ( ! is_bool( $remainingPostsToIndex ) || ( is_numeric( $progress ) && $progress > 0 && $progress < 100 ) ) ) {
$remainingPostsToIndex = absint( $remainingPostsToIndex );
?>
<div class="updated settings-error swp-in-progress<?php if ( 0 === $remainingPostsToIndex ) : ?> swp-in-progress-done<?php endif; ?>">
<div class="swp-progress-wrapper">
<p class="swp-label"><?php _e( 'Indexing is', 'searchwp' ); ?>
<span><?php _e( 'almost', 'searchwp' ); ?></span> <?php _e( 'complete', 'searchwp' ); ?>
<a class="swp-tooltip" href="#swp-tooltip-progress">?</a></p>
<div class="swp-tooltip-content" id="swp-tooltip-progress">
<?php _e( 'This process is running in the background. You can leave this page and the index will continue to be built until completion.', 'searchwp' ); ?>
</div>
<div class="swp-progress-track">
<div class="swp-progress-bar"></div>
</div>
<p class="description"><?php echo sprintf( __( 'The indexer has been <strong>temporarily scaled back</strong> to reduce server load. This is monitored automatically. <a href="%s">More information »</a>', 'searchwp' ), 'http://searchwp.com/?p=11818' ); ?></p>
</div>
示例8: load
/**
* Perform various environment checks/initializations on wp_loaded
*
* @since 1.8
*/
function load()
{
global $wp_query;
if (apply_filters('searchwp_debug', false)) {
$wp_upload_dir = wp_upload_dir();
$debug = new SearchWPDebug();
$debug->init($wp_upload_dir['basedir']);
}
do_action('searchwp_log', ' ');
do_action('searchwp_log', '========== INIT ' . $this->pid . ' ' . SEARCHWP_VERSION . ' ==========');
do_action('searchwp_log', ' ');
$this->prepare_endpoint();
// check for upgrade
new SearchWPUpgrade($this->version);
// ensure working database environment
$this->check_database_environment();
// set the registered post types
$this->postTypes = array_merge(array('post' => 'post', 'page' => 'page', 'attachment' => 'attachment'), get_post_types(array('exclude_from_search' => false, '_builtin' => false)));
// devs can customize which post types are indexed, it doesn't make
// sense to list post types that were excluded (or included (e.g. post types that don't
// allow filtration of the exclude_from_search arg))
$this->postTypes = $this->get_indexed_post_types();
// if the settings were somehow edited directly in the database
$this->settings = SWP()->validate_settings($this->settings);
// allow filtration of what SearchWP considers common words (i.e. ignores)
$this->common = apply_filters('searchwp_common_words', $this->common);
$this->alternate_indexer = apply_filters('searchwp_alternate_indexer', false);
// one-stop filter to ensure SearchWP fires
if ($this->force_run = apply_filters('searchwp_force_run', $this->force_run)) {
$wp_query->is_search = true;
}
$this->check_if_paused();
$this->set_index_update_triggers();
do_action('searchwp_load');
// handle index and/or purge requests
$this->update_index();
// reset short circuit check
$this->indexing = false;
}
示例9: plugin_row
/**
* Plugin row output (checks for minimum SearchWP version)
*/
function plugin_row()
{
if (!class_exists('SearchWP')) {
return;
}
$searchwp = SWP();
if (version_compare($searchwp->version, $this->min_searchwp_version, '<')) {
?>
<tr class="plugin-update-tr searchwp">
<td colspan="3" class="plugin-update">
<div class="update-message">
<?php
esc_html_e('SearchWP Term Synonyms requires a newer version of SearchWP', 'searchwptermsyn');
?>
</div>
</td>
</tr>
<?php
}
}
示例10: wp_get_current_user
} else {
$current_user = wp_get_current_user();
$conflicts_var = '';
$conflicts = new SearchWP_Conflicts();
if (!empty($conflicts->search_template_conflicts)) {
// strip out the full disk path
$search_template = str_replace(get_theme_root(), '', $conflicts->search_template);
$conflicts_var = $search_template . ':';
foreach ($conflicts->search_template_conflicts as $line_number => $the_conflicts) {
$conflicts_var .= $line_number . ',';
}
$conflicts_var = substr($conflicts_var, 0, strlen($conflicts_var) - 1);
// trim off the trailing comma
}
/** @noinspection PhpUndefinedFieldInspection */
$iframe_url = add_query_arg(array('support' => 1, 'f' => 6, 'dd' => 0, 'dt' => 0, 'license' => SWP()->license, 'email' => urlencode($current_user->user_email), 'url' => urlencode(home_url()), 'env' => defined('WPE_APIKEY') ? 'wpe' : 0, 'conflicts' => urlencode($conflicts_var), 'searchwp_v' => urlencode(get_option('searchwp_version')), 'wp_v' => urlencode(get_bloginfo('version')), 'php_v' => urlencode(PHP_VERSION), 'mysql_v' => urlencode($wpdb->db_version())), 'https://searchwp.com/gfembed/');
$ticket_create_url = $iframe_url;
?>
<div class="searchwp-ticket-create-wrapper">
<iframe src="<?php
echo esc_url($ticket_create_url);
?>
" frameborder="0"></iframe>
</div>
<?php
}
?>
</div>
<hr />
示例11: plugin_row
function plugin_row()
{
if (!class_exists('SearchWP')) {
return;
}
$searchwp = SWP();
if (version_compare($searchwp->version, '1.0.10', '<')) {
?>
<tr class="plugin-update-tr searchwp">
<td colspan="3" class="plugin-update">
<div class="update-message">
<?php
esc_html_e('SearchWP bbPress Integration requires SearchWP 1.0.10 or greater', 'searchwp');
?>
</div>
</td>
</tr>
<?php
}
}
示例12: plugin_row
function plugin_row()
{
if (!class_exists('SearchWP')) {
?>
<tr class="plugin-update-tr searchwp">
<td colspan="3" class="plugin-update">
<div class="update-message">
<?php
_e('SearchWP must be active to use this Extension');
?>
</div>
</td>
</tr>
<?php
} else {
?>
<?php
$searchwp = SWP();
?>
<?php
if (version_compare($searchwp->version, '1.1', '<')) {
?>
<tr class="plugin-update-tr searchwp">
<td colspan="3" class="plugin-update">
<div class="update-message">
<?php
_e('SearchWP Polylang Integration requires SearchWP 1.1 or greater', $searchwp->textDomain);
?>
</div>
</td>
</tr>
<?php
}
?>
<?php
}
}
示例13: validate_engine
/**
* Ensure that this engine exists.
*
* @since 0.1.0
*
* @param string $engine
*
* @return bool
*/
public function validate_engine($engine)
{
return SWP()->is_valid_engine($engine);
}
示例14: esc_textarea
echo esc_textarea($export_sources_json);
?>
</textarea>
</div>
<div class="swp-import-export-sources">
<h4><?php
_e('Search Engines', 'searchwp');
?>
</h4>
<p class="description"><?php
_e('Checked search engines will be included in the export', 'searchwp');
?>
</p>
<?php
$engine_id = 0;
foreach (SWP()->settings['engines'] as $searchwp_engine_id => $searchwp_export_source) {
?>
<?php
$engine_label = isset($searchwp_export_source['searchwp_engine_label']) ? $searchwp_export_source['searchwp_engine_label'] : __('Default', 'searchwp');
?>
<div class="swp-export-source">
<input type="checkbox" id="<?php
echo esc_attr(strtolower($engine_label));
?>
" checked="checked" data-swp-engine-id="<?php
echo esc_attr($searchwp_engine_id);
?>
" />
<label for="<?php
echo esc_attr(strtolower($engine_label));
?>
示例15: searchwp_set_setting
/**
* Set a setting in the SearchWP singleton. To reduce database calls this update will take place only in the singleton
* and made persistent by saving to the database when WordPress shuts down.
*
* @param $setting
* @param $value
* @param bool $group
*
* @return bool
*/
function searchwp_set_setting($setting, $value, $group = false)
{
$searchwp = SWP();
// validate the request
$setting = trim($setting);
if (empty($setting)) {
return false;
}
if (false !== $group) {
$group = trim($group);
if (empty($group)) {
return false;
}
}
// Settings in SearchWP are a bit unique. There are 'configuration' settings and 'indexer' settings. Configuration
// settings are those that configure the plugin, the search engine config, keyword weights, etc. The indexer settings
// store various details for the indexer to utilize. Since the indexer runs independently and is constantly updating
// it's internal settings, we don't want updates to these settings records to ever collide, so we're going to "route"
// them here based on their name and/or group.
$indexer_names = array('initial_index_built', 'stats', 'remaining', 'last_activity', 'total', 'done', 'in_progress', 'running', 'paused', 'processing_purge_queue', 'endpoint');
// check the setting name to see whether we need to retrieve a searchwp setting or an indexer setting
if (in_array($setting, $indexer_names) || in_array($group, $indexer_names)) {
// it's an indexer setting
$indexer_settings = get_option(SEARCHWP_PREFIX . 'indexer');
// set the setting locally and in the singleton
if (false !== $group) {
// make sure the group exists
if (!isset($indexer_settings[$group])) {
$indexer_settings[$group] = array();
}
if (!isset($searchwp->settings[$group])) {
$searchwp->settings[$group] = array();
}
$indexer_settings[$group][$setting] = $value;
// database record
$searchwp->settings[$group][$setting] = $value;
// singleton
} else {
$indexer_settings[$setting] = $value;
// database record
$searchwp->settings[$setting] = $value;
// singleton
}
// update the database record
searchwp_update_option('indexer', $indexer_settings);
} else {
// it's a SearchWP configuration
$searchwp_settings = get_option(SEARCHWP_PREFIX . 'settings');
// set the setting locally and in the singleton
if (false !== $group) {
// make sure the group exists
if (!isset($searchwp_settings[$group])) {
$searchwp_settings[$group] = array();
}
if (!isset($searchwp->settings[$group])) {
$searchwp->settings[$group] = array();
}
$searchwp_settings[$group][$setting] = $value;
// database record
$searchwp->settings[$group][$setting] = $value;
// singleton
} else {
$searchwp_settings[$setting] = $value;
// database record
$searchwp->settings[$setting] = $value;
// singleton
}
// update the database record
searchwp_update_option('settings', $searchwp_settings);
}
return true;
}