コード例 #1
0
 /**
  * register method for setting up model extensions
  *
  * @param string $model_id unique id for the extensions being setup
  * @param array   $config   {
  *               @throws EE_Error
  *               @type  array $ model_extension_paths array of folders containing DB model extensions, where each file follows the models naming convention, which is: EEME_{your_plugin_slug}_model_name_extended}.model_ext.php. Where your_plugin_slug} is really anything you want (but something having to do with your addon, like 'Calendar' or '3D_View') and model_name_extended} is the model extended. The class contained in teh file should extend EEME_Base_{model_name_extended}.model_ext.php. Where {your_plugin_slug} is really anything you want (but something having to do with your addon, like 'Calendar' or '3D_View') and {model_name_extended} is the model extended. The class contained in teh file should extend EEME_Base
  *               @type array $ class_extension_paths array of folders containing DB class extensions, where each file follows the model class extension naming convention, which is: EEE_{your_plugin_slug}_model_name_extended}.class_ext.php. Where your_plugin_slug} is something like 'Calendar','MailChimp',etc, and model_name_extended} is the name of the model extended, eg 'Attendee','Event',etc. The class contained in the file should extend EEE_Base_Class._{model_name_extended}.class_ext.php. Where {your_plugin_slug} is something like 'Calendar','MailChimp',etc, and {model_name_extended} is the name of the model extended, eg 'Attendee','Event',etc. The class contained in the file should extend EEE_Base_Class.
  * }
  *
  * @return void
  */
 public static function register($model_id = NULL, $config = array())
 {
     //required fields MUST be present, so let's make sure they are.
     if (empty($model_id) || !is_array($config) || empty($config['model_extension_paths']) && empty($config['class_extension_paths'])) {
         throw new EE_Error(__('In order to register Model extensions with EE_Register_Model_Extensions::register(), you must include a "model_id" (a unique identifier for this set of models), and an array containing the following keys: "model_extension_paths" (an array of full server paths to folders that contain model extensions), and "class_extension_paths" (an array of full server paths to folders that contain class extensions)', 'event_espresso'));
     }
     //check correct loading
     if (!did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) {
         EE_Error::doing_it_wrong(__METHOD__, sprintf(__('An attempt was made to register "%s" as a group models has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register models.', 'event_espresso'), $model_id), '4.3');
     }
     self::$_registry[$model_id] = $config;
     EE_Registry::instance()->load_helper('File');
     if (isset($config['model_extension_paths'])) {
         require_once EE_LIBRARIES . 'plugin_api/db/EEME_Base.lib.php';
         $class_to_filepath_map = EEH_File::get_contents_of_folders($config['model_extension_paths']);
         EEH_Autoloader::register_autoloader($class_to_filepath_map);
         foreach (array_keys($class_to_filepath_map) as $classname) {
             new $classname();
         }
         unset($config['model_extension_paths']);
     }
     if (isset($config['class_extension_paths'])) {
         require_once EE_LIBRARIES . 'plugin_api/db/EEE_Base_Class.lib.php';
         $class_to_filepath_map = EEH_File::get_contents_of_folders($config['class_extension_paths']);
         EEH_Autoloader::register_autoloader($class_to_filepath_map);
         foreach (array_keys($class_to_filepath_map) as $classname) {
             new $classname();
         }
         unset($config['class_extension_paths']);
     }
     foreach ($config as $unknown_key => $unknown_config) {
         throw new EE_Error(sprintf(__("The key '%s' is not a known key for registering a model", "event_espresso"), $unknown_key));
     }
 }
コード例 #2
0
 public static function registerAction($sActionHook, $oCallable)
 {
     if (did_action($sActionHook)) {
         return call_user_func_array($oCallable, array());
     }
     add_action($sActionHook, $oCallable);
 }
コード例 #3
0
ファイル: common.php プロジェクト: goodbayscott/wwr-temp
function wptuts_screen_help($contextual_help, $screen_id, $screen)
{
    // The add_help_tab function for screen was introduced in WordPress 3.3.
    if (!method_exists($screen, 'add_help_tab')) {
        return $contextual_help;
    }
    global $hook_suffix;
    // List screen properties
    $variables = '<ul style="width:50%;float:left;"> <strong>Screen variables </strong>' . sprintf('<li> Screen id : %s</li>', $screen_id) . sprintf('<li> Screen base : %s</li>', $screen->base) . sprintf('<li>Parent base : %s</li>', $screen->parent_base) . sprintf('<li> Parent file : %s</li>', $screen->parent_file) . sprintf('<li> Hook suffix : %s</li>', $hook_suffix) . '</ul>';
    // Append global $hook_suffix to the hook stems
    $hooks = array("load-{$hook_suffix}", "admin_print_styles-{$hook_suffix}", "admin_print_scripts-{$hook_suffix}", "admin_head-{$hook_suffix}", "admin_footer-{$hook_suffix}");
    // If add_meta_boxes or add_meta_boxes_{screen_id} is used, list these too
    if (did_action('add_meta_boxes_' . $screen_id)) {
        $hooks[] = 'add_meta_boxes_' . $screen_id;
    }
    if (did_action('add_meta_boxes')) {
        $hooks[] = 'add_meta_boxes';
    }
    // Get List HTML for the hooks
    $hooks = '<ul style="width:50%;float:left;"> <strong>Hooks </strong> <li>' . implode('</li><li>', $hooks) . '</li></ul>';
    // Combine $variables list with $hooks list.
    $help_content = $variables . $hooks;
    // Add help panel
    $screen->add_help_tab(array('id' => 'wptuts-screen-help', 'title' => 'Screen Information', 'content' => $help_content));
    return $contextual_help;
}
コード例 #4
0
ファイル: mercator.php プロジェクト: Tarendai/Mercator
/**
 * Perform preflight checks for Mercator
 *
 * Checks that we can actually run Mercator, then attaches the relevant actions
 * and filters to make it useful.
 */
function run_preflight()
{
    // Are we installing? Bail if so.
    if (defined('WP_INSTALLING')) {
        return;
    }
    // Are we still in sunrise stage?
    if (did_action('muplugins_loaded')) {
        warn_with_message('Mercator must be loaded in your <code>sunrise.php</code>. Check out the <a href="https://github.com/humanmade/Mercator/wiki/Installation">installation instructions</a>.');
        return;
    }
    // Are we actually on multisite?
    if (!is_multisite()) {
        warn_with_message('Mercator requires WordPress to be in <a href="http://codex.wordpress.org/Create_A_Network">multisite mode</a>.');
        return;
    }
    // Are we running a good version of WP?
    if (!function_exists('get_site_by_path')) {
        warn_with_message('Mercator requires <a href="https://wordpress.org/download/">WordPress 3.9</a> or newer. Update now.');
        return;
    }
    // Check for COOKIE_DOMAIN definition
    //
    // Note that this can't be an admin notice, as you'd never be able to log in
    // to see it.
    if (defined('COOKIE_DOMAIN')) {
        status_header(500);
        header('X-Mercator: COOKIE_DOMAIN');
        wp_die('The constant <code>COOKIE_DOMAIN</code> is defined (probably in <code>wp-config.php</code>). Please remove or comment out that <code>define()</code> line.');
    }
    // M: We have clearance, Clarence.
    // O: Roger, Roger. What's our Vector Victor?
    startup();
}
コード例 #5
0
/**
 * Include scripts to the options page only
 */
function automobile_theme_options_scripts()
{
    if (!did_action('wp_enqueue_media')) {
        wp_enqueue_media();
    }
    wp_enqueue_script('automobile_upload', plugins_url('/js/upload.js', __FILE__));
}
コード例 #6
0
ファイル: mercator.php プロジェクト: tholu/Mercator
/**
 * Perform preflight checks for Mercator
 *
 * Checks that we can actually run Mercator, then attaches the relevant actions
 * and filters to make it useful.
 */
function run_preflight()
{
    // Are we installing? Bail if so.
    if (defined('WP_INSTALLING')) {
        return;
    }
    // Are we still in sunrise stage?
    if (did_action('muplugins_loaded')) {
        warn_with_message('Mercator must be loaded in your <code>sunrise.php</code>. Check out the <a href="https://github.com/humanmade/Mercator/wiki/Installation">installation instructions</a>.');
        return;
    }
    // Are we actually on multisite?
    if (!is_multisite()) {
        warn_with_message('Mercator requires WordPress to be in <a href="http://codex.wordpress.org/Create_A_Network">multisite mode</a>.');
        return;
    }
    // Are we running a good version of WP?
    if (!function_exists('get_site_by_path')) {
        warn_with_message('Mercator requires <a href="https://wordpress.org/download/">WordPress 3.9</a> or newer. Update now.');
        return;
    }
    // M: We have clearance, Clarence.
    // O: Roger, Roger. What's our Vector Victor?
    startup();
}
 public function __construct($sPluginFilePath, $sPluginHookPrefix = '', $sSetUpHook = 'plugins_loaded', $iPriority = 10)
 {
     if ($this->_hasLoaded()) {
         return;
     }
     $this->sFilePath = $sPluginFilePath;
     $this->bIsAdmin = is_admin();
     $this->sHookPrefix = $sPluginHookPrefix;
     $this->sSetUpHook = $sSetUpHook;
     $this->iPriority = $iPriority;
     $_bValid = $this->start();
     if (false === $_bValid) {
         return;
     }
     $this->setConstants();
     $this->setGlobals();
     $this->_registerClasses();
     register_activation_hook($this->sFilePath, array($this, 'replyToPluginActivation'));
     register_deactivation_hook($this->sFilePath, array($this, 'replyToPluginDeactivation'));
     if (!$this->sSetUpHook || did_action($this->sSetUpHook)) {
         $this->_replyToLoadPluginComponents();
     } else {
         add_action($this->sSetUpHook, array($this, '_replyToLoadPluginComponents'), $this->iPriority);
     }
     add_action('init', array($this, 'setLocalization'));
     $this->construct();
 }
 /**
  *    Method for registering new EE_PMT_Base children
  *
  * @since    4.5.0
  * @param string $payment_method_id		a unique identifier for this set of modules Required.
  * @param  array $setup_args 		an array of arguments provided for registering modules Required.{
  *	@type string[] $payment_method_paths each element is the folder containing the EE_PMT_Base child class
  *		(eg, 'public_html/wp-content/plugins/my_plugin/Payomatic/' which contains the files
  *		EE_PMT_Payomatic.pm.php)
  * }
  * @throws EE_Error
  * @internal param string payment_method_paths 	an array of full server paths to folders containing any EE_PMT_Base children, or to the EED_Module files themselves
  * @return void
  */
 public static function register($payment_method_id = NULL, $setup_args = array())
 {
     //required fields MUST be present, so let's make sure they are.
     if (empty($payment_method_id) || !is_array($setup_args) || empty($setup_args['payment_method_paths'])) {
         throw new EE_Error(__('In order to register Payment Methods with EE_Register_Payment_Method::register(), you must include a "payment_method_id" (a unique identifier for this set of modules), and an array containing the following keys: "payment_method_paths" (an array of full server paths to folders that contain modules, or to the module files themselves)', 'event_espresso'));
     }
     //make sure we don't register twice
     if (isset(self::$_settings[$payment_method_id])) {
         return;
     }
     //make sure this was called in the right place!
     if (!did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')) {
         EE_Error::doing_it_wrong(__METHOD__, __('An attempt to register modules has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register modules.', 'event_espresso'), '4.3.0');
     }
     //setup $_settings array from incoming values.
     self::$_settings[$payment_method_id] = array('payment_method_paths' => isset($setup_args['payment_method_paths']) ? (array) $setup_args['payment_method_paths'] : array());
     // add to list of modules to be registered
     add_filter('FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', array('EE_Register_Payment_Method', 'add_payment_methods'));
     /**
      * If EE_Payment_Method_Manager::register_payment_methods has already been called, we need it to be called again
      * (because it's missing the paymetn method we JUST registered here). We are assuming EE_Register_payment_method::register()
      * will be called only once per payment method from an addon, so going with that assumption we should always do this.
      * If that assumption is false, we should verify this newly-registered paymetn method isn't on the EE_Payment_Method_Manager::_payment_method_types array before calling this (this code should be changed to improve performance)
      */
     if (did_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods')) {
         EE_Registry::instance()->load_lib('Payment_Method_Manager');
         EE_Payment_Method_Manager::instance()->maybe_register_payment_methods(TRUE);
     }
 }
コード例 #9
0
 /**
  * Initialize the plugin, registering WordPress hooks.
  */
 public static function init()
 {
     if (did_action('plugins_loaded')) {
         self::plugin_textdomain();
     } else {
         add_action('plugins_loaded', array('SemanticLinkbacksPlugin', 'plugin_textdomain'), 99);
     }
     // hook into linkback functions to add more semantics
     // FIXME temporarily removed because it does not support updates
     // add_action( 'comment_post', array( 'SemanticLinkbacksPlugin', 'linkback_fix' ), 9 );
     add_action('pingback_post', array('SemanticLinkbacksPlugin', 'linkback_fix'), 9);
     // FIXME temporarily added because the `comment_post` does not support updates
     add_action('trackback_post', array('SemanticLinkbacksPlugin', 'linkback_fix'), 9);
     add_action('webmention_post', array('SemanticLinkbacksPlugin', 'linkback_fix'), 9);
     add_filter('pre_get_avatar_data', array('SemanticLinkbacksPlugin', 'pre_get_avatar_data'), 11, 5);
     // To extend or to override the default behavior, just use the `comment_text` filter with a lower
     // priority (so that it's called after this one) or remove the filters completely in
     // your code: `remove_filter('comment_text', array('SemanticLinkbacksPlugin', 'comment_text_add_cite'), 11);`
     add_filter('comment_text', array('SemanticLinkbacksPlugin', 'comment_text_add_cite'), 11, 3);
     add_filter('comment_text', array('SemanticLinkbacksPlugin', 'comment_text_excerpt'), 12, 3);
     add_filter('comment_excerpt', array('SemanticLinkbacksPlugin', 'comment_text_excerpt'), 5, 2);
     add_filter('get_comment_link', array('SemanticLinkbacksPlugin', 'get_comment_link'), 99, 3);
     add_filter('get_comment_author_url', array('SemanticLinkbacksPlugin', 'get_comment_author_url'), 99, 3);
     add_filter('get_avatar_comment_types', array('SemanticLinkbacksPlugin', 'get_avatar_comment_types'));
     add_filter('comment_class', array('SemanticLinkbacksPlugin', 'comment_class'), 10, 4);
 }
 public function test__transition_post_status__ignore_when_locked()
 {
     // The first update sets the lock so the action should only fire once when updating twice
     \wp_transition_post_status('publish', 'publish', $this->post);
     \wp_transition_post_status('publish', 'publish', $this->post);
     $this->assertEquals(1, did_action('wpcom_vip_bump_lastpostmodified'));
 }
 /**
  * Used to register capability items with EE core.
  *
  * @since 4.5.0
  *
  * @param string $cap_reference usually will be a class name that references capability related items setup for something.
  * @param array  $setup_args    {
  *                              An array of items related to registering capabilities.
  *                              @type array $capabilities 	An array mapping capability strings to core WP Role.  Something like array( 'administrator' => array( 'read_cap', 'edit_cap', 'delete_cap'), 'author' => array( 'read_cap' ) ).
  *                              @type array $capability_maps EE_Meta_Capability_Map[]   @see EE_Capabilities.php for php docs on these objects.  Should be indexed by the classname for the capability map and values representing the arguments for the map.
  * }
  * @throws EE_Error
  * @return void
  */
 public static function register($cap_reference = NULL, $setup_args = array())
 {
     //required fields MUST be present, so let's make sure they are.
     if (!isset($cap_reference) || !is_array($setup_args) || empty($setup_args['capabilities'])) {
         throw new EE_Error(__('In order to register capabilities with EE_Register_Capabilities::register, you must include a unique name to reference the capabilities being registered, plus an array containing the following keys: "capabilities".', 'event_espresso'));
     }
     //make sure we don't register twice
     if (isset(self::$_registry[$cap_reference])) {
         return;
     }
     //make sure this is not registered too late or too early.
     if (!did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')) {
         EE_Error::doing_it_wrong(__METHOD__, sprintf(__('%s has been registered too late.  Please ensure that EE_Register_Capabilities::register has been called at some point before the "AHEE__EE_System___detect_if_activation_or_upgrade__begin" action hook has been called.', 'event_espresso'), $cap_reference), '4.5.0');
     }
     //some preliminary sanitization and setting to the $_registry property
     self::$_registry[$cap_reference] = array('caps' => isset($setup_args['capabilities']) && is_array($setup_args['capabilities']) ? $setup_args['capabilities'] : array(), 'cap_maps' => isset($setup_args['capability_maps']) ? $setup_args['capability_maps'] : array());
     //set initial caps (note that EE_Capabilities takes care of making sure that the caps get added donly once)
     add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array('EE_Register_Capabilities', 'register_capabilities'), 10);
     //add filter for cap maps
     add_filter('FHEE__EE_Capabilities___set_meta_caps__meta_caps', array('EE_Register_Capabilities', 'register_cap_maps'), 10);
     //init_role_caps to register new capabilities
     if (is_admin()) {
         EE_Registry::instance()->load('Capabilities');
         EE_Capabilities::instance()->init_caps();
     }
 }
コード例 #12
0
 function display($args = array())
 {
     /* Use the generic_content action if it's set.  See http://core.trac.wordpress.org/ticket/20509 */
     if ($this->get_setting('mode', 'default') == 'default' && has_action('generic_content') && !did_action('generic_content')) {
         return do_action('generic_content');
     }
     /* Since it's impossible to get the $wp_query in its correct form when loading the content from admin-ajax.php, we will display this notice. */
     if (headway_get('ve-live-content-query', $this->block, false) && $this->get_setting('mode', 'default') == 'default') {
         echo '<div class="alert alert-yellow" style="margin: 5px;"><p><strong>Please note:</strong> What\'s being displayed here in the Content Block may not be correct.  When viewing the site outside of the Visual Editor, you will see the correct content.</p></div>';
     }
     /* If LoopBuddy is activated, we'll strictly rely on it for the query setup and how the content is displayed. */
     if (class_exists('pluginbuddy_loopbuddy')) {
         global $pluginbuddy_loopbuddy;
         $loopbuddy_query = $this->get_setting('loopbuddy-query', -1);
         $loopbuddy_layout = $this->get_setting('loopbuddy-layout', -1);
         if (isset($pluginbuddy_loopbuddy) && $loopbuddy_query !== -1) {
             echo $pluginbuddy_loopbuddy->render_loop($loopbuddy_query, $loopbuddy_layout);
             $this->remove_hooks();
             return;
         }
     }
     /* Display the 404 text if it's a 404 (has to be default behavior) */
     if (is_404() && $this->get_setting('mode', 'default') == 'default' && !headway_get('ve-live-content-query', $this->block, false)) {
         $this->remove_hooks();
         return $this->display_404();
     }
     /* Display loop like normal if nothing else fires first */
     $this->loop($args);
     $this->remove_hooks();
     wp_reset_query();
 }
コード例 #13
0
 /**
  * Test for the get_answer() method.
  *
  * @covers HookOracle::get_answer()
  *
  * @return void
  */
 public function test_get_answer()
 {
     $testee = new HookOracle();
     $this->assertSame('42', $testee->get_answer(), 'get_answer() should return the expected answer.');
     $this->assertSame(1, did_action('give_answer'));
     $this->assertTrue(Monkey::filters()->applied('the_answer') > 0);
 }
コード例 #14
0
 public function output_filters()
 {
     global $listify_facetwp;
     if (did_action('listify_output_results') && 'side' == $this->position()) {
         return;
     }
     if ('side' == $this->position()) {
         $after = $before = '';
     } else {
         $before = '<div class="row">';
         $after = '</div>';
     }
     $facets = $listify_facetwp->get_facets();
     $count = count($facets);
     $count = floor(12 / ($count == 0 ? 1 : $count));
     $columns = 'col-lg-' . $count . ' col-md-6 col-sm-12';
     $class = '';
     if ('side' == $this->position()) {
         $columns = null;
         $class = 'widget';
     }
     echo '<a href="#" data-toggle=".job_filters" class="js-toggle-area-trigger">' . __('Toggle Filters', 'listify') . '</a>';
     echo '<div class="job_filters content-box ' . $this->position() . '">';
     echo $before;
     echo $this->output_facets();
     echo $after;
     echo '</div>';
 }
コード例 #15
0
 /**
  * Constructor
  */
 public static function construct()
 {
     /**
      * The auto-switch should always work
      */
     self::_load_plugin_list();
     self::_setup_automatic_switch();
     /**
      * The rest relies on user privileges, and therefore must wait until necessary WP functions are loaded
      */
     if (!did_action('plugins_loaded')) {
         _doing_it_wrong(__METHOD__, __('Must call in of after the "plugins_loaded" action.', 'redux-framework'), '14.03.19');
         return;
     }
     /**
      * Low-level users won't see anything
      */
     if (!current_user_can(TIVWP_DM::MIN_CAPABILITY)) {
         return;
     }
     /**
      * The main actions happen in the admin area
      */
     if (is_admin()) {
         self::_setup_i18n();
         self::_setup_plugin_composer();
         self::_setup_admin_interface();
     }
 }
コード例 #16
0
 /**
  * @param string $id Unique
  * @param array $data (optional)
  * array(
  *  'render'   => callback // The callback that will render the form's html
  *  'validate' => callback // The callback that will validate user input
  *  'save'     => callback // The callback that will save successfully validated user input
  *  'attr'     => array()  // Custom <form ...> attributes
  * )
  */
 public function __construct($id, $data = array())
 {
     if (isset(self::$forms[$id])) {
         trigger_error(sprintf(__('Form with id "%s" was already defined', 'fw'), $id), E_USER_ERROR);
     }
     $this->id = $id;
     self::$forms[$this->id] =& $this;
     if (!isset($data['attr']) || !is_array($data['attr'])) {
         $data['attr'] = array();
     }
     $data['attr']['id'] = 'fw_form_' . $this->id;
     if (isset($data['attr']['method'])) {
         $data['attr']['method'] = strtolower($data['attr']['method']);
         $data['attr']['method'] = in_array($data['attr']['method'], array('get', 'post')) ? $data['attr']['method'] : 'post';
     } else {
         $data['attr']['method'] = 'post';
     }
     if (!isset($data['attr']['action'])) {
         $data['attr']['action'] = '';
     }
     $this->attr = $data['attr'];
     $this->callbacks = array('render' => empty($data['render']) ? false : $data['render'], 'validate' => empty($data['validate']) ? false : $data['validate'], 'save' => empty($data['save']) ? false : $data['save']);
     if (did_action('wp_loaded')) {
         // in case if form instance was created after action
         $this->_validate_and_save();
     } else {
         // attach to an action before 'send_headers' action, to be able to do redirects
         add_action('wp_loaded', array($this, '_validate_and_save'), 101);
     }
 }
コード例 #17
0
 /**
  * @throws EE_Error
  * @return WP_Filesystem_Base
  */
 private static function _get_wp_filesystem()
 {
     global $wp_filesystem;
     // no filesystem setup ???
     if (!$wp_filesystem instanceof WP_Filesystem_Base) {
         // if some eager beaver's just trying to get in there too early...
         if (!did_action('wp_loaded')) {
             $msg = __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso');
             if (WP_DEBUG) {
                 $msg .= '<br />' . __('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso');
             }
             throw new EE_Error($msg);
         } else {
             // should be loaded if we are past the wp_loaded hook...
             if (!function_exists('WP_Filesystem')) {
                 require_once ABSPATH . 'wp-admin/includes/file.php';
             }
             // basically check for direct or previously configured access
             if (!WP_Filesystem()) {
                 // turn on output buffering so that we can capture the credentials form
                 ob_start();
                 $credentials = request_filesystem_credentials('');
                 // store credentials form for the time being
                 EEH_File::$_credentials_form = ob_get_clean();
                 // if credentials do NOT exist
                 if ($credentials === FALSE) {
                     add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999);
                     throw new EE_Error(__('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso'));
                 }
             }
         }
     }
     return $wp_filesystem;
 }
コード例 #18
0
 function load_data_types()
 {
     global $data_types_list;
     // $data_types_path = get_theme_root() . "/runway-framework/data-types";
     $data_types_path = FRAMEWORK_DIR . 'data-types';
     $data_types_base = $data_types_path . "/data-type.php";
     if (!file_exists($data_types_path) || !file_exists($data_types_base)) {
         wp_die("Error: has no data types.");
     } else {
         include_once $data_types_base;
         $data_types_array = include_data_types($data_types_path);
         foreach ($data_types_array as $name => $path) {
             $data_type_slug = basename($path, '.php');
             if ($name == 'fileupload-type.php') {
                 if (!did_action('wp_enqueue_media')) {
                     wp_enqueue_media();
                 }
                 // Needed for upload field
             }
             $data_types_list[$data_type_slug] = array('filename' => $name, 'classname' => ucfirst(str_replace('-', '_', $data_type_slug)));
             // Unsupported in old PHP versions
             $data_types_list[$data_type_slug]['classname']::assign_actions_and_filters();
         }
     }
 }
コード例 #19
0
ファイル: media.php プロジェクト: plance/wp-plugin-library
    public function __construct()
    {
        add_action('admin_enqueue_scripts', function () {
            if (did_action('wp_enqueue_media') == false) {
                wp_enqueue_media();
            }
            wp_add_inline_script('image-edit', '
				jQuery(".plance-medial-button-select").live("click",function()
				{
					var send_attachment_bkp = wp.media.editor.send.attachment;
					var $btn = jQuery(this);
					wp.media.editor.send.attachment = function(props, attachment)
					{
						jQuery($btn).parents(".plance-medial").find(".plance-medial-img").attr("src", attachment.url);
						jQuery($btn).parents(".plance-medial").find(".plance-medial-src").val(attachment.url);
						wp.media.editor.send.attachment = send_attachment_bkp;
					}
					wp.media.editor.open($btn);

					return false;
				});

				jQuery(".plance-medial-button-remove").live("click",function()
				{
					var $p = jQuery(this).parents(".plance-medial");
					var src = $p.find(".plance-medial-img").attr("data-src");
					$p.find(".plance-medial-img").attr("src", src);
					$p.find(".plance-medial-src").val("");

					return false;
				});
			');
        });
    }
コード例 #20
0
 /**
  * Forces SSL on specific Posts/Pages, or any page for that matter.
  *
  * Triggered by Custom Field: `s2member_force_ssl = yes|port#`
  *
  * Triggered by: `?s2-ssl` or `?s2-ssl=yes|port#`.
  *
  * @package s2Member\SSL
  * @since 3.5
  *
  * @attaches-to ``add_action("init");``
  * @also-attaches-to ``add_action("wp");``
  *
  * @return null Possibly exiting script execution after redirection to SSL variation.
  */
 public static function check_force_ssl()
 {
     static $forced = false;
     // Only force SSL once.
     global $post;
     // We need this global reference to ``$post``.
     do_action("ws_plugin__s2member_before_check_force_ssl", get_defined_vars());
     if (!$forced) {
         // Only force SSL here once. We definitely do NOT need to run this particular routine more than ONE time.
         if (!c_ws_plugin__s2member_systematics::is_wp_systematic_use_page()) {
             $s2_ssl_gv = apply_filters("ws_plugin__s2member_check_force_ssl_get_var_name", "s2-ssl", get_defined_vars());
             $_g_s2_ssl = isset($_GET[$s2_ssl_gv]) && (!strlen($_GET[$s2_ssl_gv]) || !preg_match("/^(0|no|off|false)\$/i", $_GET[$s2_ssl_gv])) ? !strlen($_GET[$s2_ssl_gv]) ? true : $_GET[$s2_ssl_gv] : false;
             $force_ssl = apply_filters("ws_plugin__s2member_check_force_ssl", $_g_s2_ssl, get_defined_vars());
             if ($force_ssl || did_action("wp") && is_singular() && is_object($post) && ($force_ssl = get_post_meta($post->ID, "s2member_force_ssl", true))) {
                 if (!preg_match("/^(0|no|off|false)\$/i", (string) $force_ssl) && ($forced = true)) {
                     // Make sure it's NOT a negative variation.
                     c_ws_plugin__s2member_ssl_in::force_ssl(get_defined_vars());
                 }
             }
             // Call inner routine now.
         }
     }
     do_action("ws_plugin__s2member_after_check_force_ssl", get_defined_vars());
     return;
 }
コード例 #21
0
ファイル: api.php プロジェクト: hscale/webento
/**
 * Register a connection between two post types.
 *
 * This creates the appropriate meta box in the admin edit screen.
 *
 * Takes the following parameters, as an associative array:
 *
 * - 'name' - string A unique identifier for this connection type.
 *
 * - 'from' - string|array The first end of the connection.
 *
 * - 'from_query_vars' - array Additional query vars to pass to WP_Query. Default: none.
 *
 * - 'to' - string|array The second end of the connection.
 *
 * - 'to_query_vars' - array Additional query vars to pass to WP_Query. Default: none.
 *
 * - 'fields' - array( key => Title ) Metadata fields editable by the user. Default: none.
 *
 * - 'cardinality' - string How many connection can each post have: 'one-to-many', 'many-to-one' or 'many-to-many'. Default: 'many-to-many'
 *
 * - 'duplicate_connections' - bool Whether to allow more than one connection between the same two posts. Default: false.
 *
 * - 'self_connections' - bool Whether to allow a post to connect to itself. Default: false.
 *
 * - 'sortable' - bool|string Whether to allow connections to be ordered via drag-and-drop. Can be 'from', 'to', 'any' or false. Default: false.
 *
 * - 'title' - string|array The box's title. Default: 'Connected {$post_type}s'
 *
 * - 'from_labels' - array Additional labels for the admin box (optional)
 *
 * - 'to_labels' - array Additional labels for the admin box (optional)
 *
 * - 'reciprocal' - bool For indeterminate connections: True means all connections are displayed in a single box. False means 'from' connections are shown in one box and 'to' connections are shown in another box. Default: false.
 *
 * - 'admin_box' - bool|string|array Whether and where to show the admin connections box.
 *
 * - 'can_create_post' - bool Whether to allow post creation via the connection box. Default: true.
 *
 * @param array $args
 *
 * @return bool|object False on failure, P2P_Connection_Type instance on success.
 */
function p2p_register_connection_type($args)
{
    if (!did_action('init')) {
        trigger_error("Connection types should not be registered before the 'init' hook.");
    }
    $argv = func_get_args();
    if (count($argv) > 1) {
        $args = array();
        foreach (array('from', 'to', 'reciprocal') as $i => $key) {
            if (isset($argv[$i])) {
                $args[$key] = $argv[$i];
            }
        }
    } else {
        $args = $argv[0];
    }
    if (isset($args['id'])) {
        $args['name'] = _p2p_pluck($args, 'id');
    }
    if (isset($args['prevent_duplicates'])) {
        $args['duplicate_connections'] = !$args['prevent_duplicates'];
    }
    if (isset($args['show_ui'])) {
        $args['admin_box'] = array('show' => _p2p_pluck($args, 'show_ui'));
        if (isset($args['context'])) {
            $args['admin_box']['context'] = _p2p_pluck($args, 'context');
        }
    }
    $ctype = P2P_Connection_Type_Factory::register($args);
    do_action('p2p_registered_connection_type', $ctype, $args);
    return $ctype;
}
コード例 #22
0
ファイル: core.php プロジェクト: datalynk/quizzlestick
 public function __construct($args = array())
 {
     // Load our helper function
     require_once 'icit-helpers.php';
     // notification helper
     require_once 'icit-notices.php';
     // Makes it easier to set default options on get_option.
     require_once 'icit-defaults.php';
     if (isset($args['dir'])) {
         $this->dir = $args['dir'];
     }
     if (isset($args['url'])) {
         $this->url = $args['url'];
     }
     // Set the folder for the core
     $this->dir === null && ($this->dir = dirname(__FILE__));
     // Load the translation stuff..
     $locale = get_locale();
     if (file_exists($this->dir . '/lang/' . self::DOM . '-' . $locale . '.mo')) {
         load_textdomain(self::DOM, $this->dir . '/lang/' . self::DOM . '-' . $locale . '.mo');
     }
     // add core class autoloaders
     spl_autoload_register(array($this, '__autoload'));
     //spl_autoload_register( array( $this, '__autoload_psr0' ) );
     spl_autoload_register(array($this, '__autoload_wp'));
     if (did_action('init') && !(isset($_GET['action']) && $_GET['action'] == 'activate' && isset($_GET['plugin']))) {
         _doing_it_wrong('icit_core', __('icit_core should be included at the top of your theme or plug-in file and should load before the init action.', self::DOM), 'icit_core:1.0');
     } else {
         if (!did_action('plugins_loaded') && !did_action('setup_theme') && $this->is_plugin == null) {
             $this->is_plugin = true;
         } elseif (did_action('plugins_loaded') && !did_action('setup_theme') && $this->is_plugin === null) {
             $this->is_plugin = false;
         }
     }
 }
コード例 #23
0
/**
 * This code generates the angularjs html views templates
 * It uses HTTP-API with  wp_remote_get()
 * */
function angp_get_template_content($new_status, $old_status)
{
    global $post;
    if (isset($post->post_name)) {
        $post_slug = $post->post_name;
        $file = get_template_directory() . '/library/views/pages/' . $post_slug . '.html';
        if ($old_status != 'trash' && $new_status == 'trash') {
            if (file_exists($file)) {
                unlink($file);
            }
        }
    }
    if ($old_status != 'publish' && $new_status == 'publish' || did_action('wp_insert_post') === 1) {
        angp_get_page_http_api(site_url(), 'newsloop');
        $pages = get_pages(array('sort_order' => 'asc'));
        if (!empty($pages)) {
            foreach ($pages as $page) {
                $slug = $page->post_name;
                $url = get_page_link($page->ID);
                angp_set_session('index.php', 'template_req');
                angp_get_page_http_api($url, $slug);
            }
        }
    }
}
コード例 #24
0
ファイル: open-graph.php プロジェクト: kalushta/darom
 public function tags()
 {
     if (!did_action('pre_get_posts')) {
         return array();
     }
     $queried_object = get_queried_object();
     $tags = array();
     $default_tags = array('og:type' => 'website', 'og:locale' => get_locale(), 'og:site_name' => get_bloginfo('name'), 'og:image' => $this->get_image_url());
     if (is_front_page()) {
         $tags = array('og:url' => home_url('/'), 'og:title' => get_bloginfo('name'), 'og:description' => get_bloginfo('description'));
     } else {
         if (is_singular()) {
             $tags = array('og:type' => 'article', 'og:url' => get_permalink($queried_object), 'og:title' => get_the_title($queried_object), 'og:description' => $this->generate_preview($queried_object->post_content), 'article:published_time' => date('c', strtotime($queried_object->post_date_gmt)), 'article:modified_time' => date('c', strtotime($queried_object->post_modified_gmt)), 'article:author' => get_author_posts_url($queried_object->post_author));
         } else {
             if (is_tax() || is_category() || is_tag()) {
                 $tags = array('og:url' => get_term_link($queried_object), 'og:title' => $queried_object->name, 'og:description' => $this->generate_preview($queried_object->description));
             } else {
                 if (is_author()) {
                     $tags = array('og:type' => 'profile', 'og:url' => get_author_posts_url($queried_object->ID), 'og:title' => $queried_object->display_name, 'og:description' => $this->generate_preview($queried_object->user_description), 'profile:first_name' => get_the_author_meta('first_name', $queried_object->ID), 'profile:last_name' => get_the_author_meta('last_name', $queried_object->ID));
                 }
             }
         }
     }
     $tags = array_merge($default_tags, $tags);
     return apply_filters('appthemes_open_graph_meta_tags', $tags);
 }
コード例 #25
0
ファイル: WpLatte.php プロジェクト: ssuhss/Begara
    /**
     * @param string $file Absolut path to template file
     * @param array $params Variables for template
     */
    public function __construct($file, $params)
    {
        $prefix = "main-";
        $file = basename($file, '.php');
        $file = self::$templatesDir . "/%s{$file}.php";
        if (is_file(sprintf($file, $prefix))) {
            $file = sprintf($file, $prefix);
        } else {
            $prefix = "";
            $file = sprintf($file, $prefix);
        }
        parent::__construct($file);
        $params['site'] = WpLatteSiteEntity::getInstance();
        if (file_exists(self::$templatesDir . '/main-layout.php')) {
            $params['layout'] = 'main-layout.php';
        } elseif (file_exists(self::$templatesDir . '/layout.php')) {
            $params['layout'] = 'layout.php';
        } else {
            $params['layout'] = '@layout.php';
        }
        $params['headerNotCalled'] = did_action('get_header') == 0;
        $params['footerNotCalled'] = did_action('get_footer') == 0;
        $params['sidebarNotCalled'] = did_action('get_sidebar') == 0;
        $this->setParams($params);
        $this->registerHelperLoader('NTemplateHelpers::loader');
        $this->registerHelper("printf", "sprintf");
        $this->setCacheStorage(new NPhpFileStorage(realpath(self::$cacheDir)));
        $this->onPrepareFilters[] = create_function('$template', '
			$engine = new NLatteFilter();
			WpLatteMacros::install($engine->parser);
			$template->registerFilter($engine);
			');
    }
コード例 #26
0
ファイル: choose-lang-url.php プロジェクト: MaryMaffka/dpm
 public function __construct(&$polylang)
 {
     parent::__construct($polylang);
     if (!did_action('pll_language_defined')) {
         $this->set_language_from_url();
     }
 }
コード例 #27
0
/**
 * Helper function to output a _doing_it_wrong message when applicable.
 *
 * @ignore
 * @since 4.2.0
 *
 * @param string $function Function name.
 */
function _wp_scripts_maybe_doing_it_wrong($function)
{
    if (did_action('init')) {
        return;
    }
    _doing_it_wrong($function, sprintf(__('Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.'), '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>'), '3.3');
}
コード例 #28
0
ファイル: Wordpress.php プロジェクト: atikahmed/joomla-probid
 /**
  * @param $file
  */
 public function addStyle($file)
 {
     global $wp_styles;
     $path_parts = pathinfo($file);
     //check if its a file or handle
     if ($path_parts['extension'] == 'css') {
         //differentiate between the plugin files and the widget files
         if (strpos($file, 'widget') === false) {
             $handle = 'rok_' . str_replace('.', '_', basename($file));
         } else {
             $handle = 'rok_widget_' . str_replace('.', '_', basename($file));
         }
         //check if wordpress head has run
         if (!did_action('wp_head')) {
             wp_register_style($handle, $file);
             wp_enqueue_style($handle);
         } else {
             //wordpress head already ran so...
             $file_root = str_replace($wp_styles->base_url, ABSPATH, $file);
             if (file_exists($file_root)) {
                 echo "<link rel='stylesheet' id='{$handle}' href='{$file}' type='text/css' media='all' />\n";
             }
         }
     } else {
         //might be a handle
         wp_enqueue_style($file);
     }
 }
コード例 #29
0
function infogr_media_popup_content()
{
    global $status;
    // Check if the wp_editor() function has been called.
    if (!did_action('before_wp_tiny_mce') or $status) {
        return;
    }
    ?>
  <div id="infogr_media_popup">
    <div class="infogr_inner">
      <span id="close_infogr_popup"></span>
      <?php 
    // Check if the plugins setting is wrong
    global $inforgam;
    $inforgam->is_valid() ? infogr_add_media_popup() : infogr_message_popup();
    ?>
      <div class="infogr-popup-footer">
        <!-- add embed form -->
        <a href="https://blog.infogr.am/new-infogram-wordpress-plugin/" target="_blank" class="infogr_faq"><?php 
    echo _e('Need help with plugin?', 'Infogr.am');
    ?>
</a>
        <form action="" method="POST" id="infogr_embed">
          <input type="text" id="infogr_add_embed" placeholder="<?php 
    echo _e('Embed from a link. Paste the Infogr.am URL to the chart or infographic here.', 'Infogr.am');
    ?>
"/>
          <input type="submit" value="Embed"/>
        </form>
      </div>
    </div>
  </div>
<?php 
}
コード例 #30
0
ファイル: ingot_bootstrap.php プロジェクト: Ramoonus/ingot
 /**
  * Loads ingot if not already loaded.
  *
  * @since 0.0.5
  */
 public static function maybe_load()
 {
     if (did_action('ingot_loaded')) {
         return;
     }
     if (!defined('INGOT_DEV_MODE')) {
         /**
          * Puts Ingot into dev mode
          *
          * Don't use on a live site -- makes API totally open
          *
          * @since 0.0.5
          */
         define('INGOT_DEV_MODE', false);
     }
     $load = true;
     if (!version_compare(PHP_VERSION, '5.5.0', '>=')) {
         $load = false;
     }
     $autoloader = dirname(__FILE__) . '/vendor/autoload.php';
     if (!file_exists($autoloader)) {
         $load = false;
     }
     if ($load) {
         add_filter('ingot_force_update_table', '__return_true');
         if (!did_action('ingot_loaded')) {
             include_once $autoloader;
             self::maybe_upgrade();
             self::add_tables();
             if (self::check_if_tables_exist()) {
                 ingot\testing\ingot::instance();
                 //make admin go in admin
                 if (is_admin()) {
                     new \ingot\ui\admin\app\load();
                 }
                 add_action('init', array(__CLASS__, 'init_cookies'), 25);
                 add_action('ingot_cookies_set', array(__CLASS__, 'init_price_tests'));
                 /**
                  * Runs when Ingot has loaded.
                  *
                  * @since 0.0.5
                  *
                  */
                 do_action('ingot_loaded');
             } else {
                 if (is_admin()) {
                     printf('<div class="error"><p>%s</p></div>', __('Ingot Not Loaded', 'ingot'));
                 }
                 /**
                  * Runs if Ingot failed to load
                  *
                  * @since 0.3.0
                  *
                  */
                 do_action('ingot_loaded_failed');
                 return;
             }
         }
     }
 }