/**
  * 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();
     }
 }
 /**
  *
  * @throws EE_Error
  * @return string of html to display the field
  */
 public function display()
 {
     $input = $this->get_input();
     //d( $input );
     $multi = count($input->options()) > 1 ? TRUE : FALSE;
     $input->set_label_sizes();
     $label_size_class = $input->get_label_size_class();
     $html = '';
     if (!is_array($input->raw_value()) && $input->raw_value() !== NULL) {
         EE_Error::doing_it_wrong('EE_Checkbox_Display_Strategy::display()', sprintf(__('Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', 'event_espresso'), $input->html_id(), var_export($input->raw_value(), true), $input->html_name() . '[]'), '4.8.1');
     }
     $input_raw_value = (array) $input->raw_value();
     foreach ($input->options() as $value => $display_text) {
         $value = $input->get_normalization_strategy()->unnormalize_one($value);
         $html_id = $multi ? $this->get_sub_input_id($value) : $input->html_id();
         $html .= EEH_HTML::nl(0, 'checkbox');
         $html .= '<label for="' . $html_id . '" id="' . $html_id . '-lbl" class="ee-checkbox-label-after' . $label_size_class . '">';
         $html .= EEH_HTML::nl(1, 'checkbox');
         $html .= '<input type="checkbox"';
         $html .= ' name="' . $input->html_name() . '[]"';
         $html .= ' id="' . $html_id . '"';
         $html .= ' class="' . $input->html_class() . '"';
         $html .= ' style="' . $input->html_style() . '"';
         $html .= ' value="' . esc_attr($value) . '"';
         $html .= !empty($input_raw_value) && in_array($value, $input_raw_value) ? ' checked="checked"' : '';
         $html .= ' ' . $this->_input->other_html_attributes();
         $html .= '>&nbsp;';
         $html .= $display_text;
         $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>';
     }
     return $html;
 }
 /**
  *
  * @throws EE_Error
  * @return string of html to display the field
  */
 function display()
 {
     if (!$this->_input instanceof EE_Form_Input_With_Options_Base) {
         throw new EE_Error(sprintf(__("Cannot use Checkbox Display Strategy with an input that doesn't have options", "event_espresso")));
     }
     //d( $this->_input );
     $multi = count($this->_input->options()) > 1 ? TRUE : FALSE;
     $this->_input->set_label_sizes();
     $label_size_class = $this->_input->get_label_size_class();
     $html = '';
     if (!is_array($this->_input->raw_value()) && $this->_input->raw_value() !== NULL) {
         EE_Error::doing_it_wrong('EE_Checkbox_Display_Strategy::display()', sprintf(__('Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', 'event_espresso'), $this->_input->html_id(), var_export($this->_input->raw_value(), true), $this->_input->html_name() . '[]'), '4.8.1');
     }
     $input_raw_value = (array) $this->_input->raw_value();
     foreach ($this->_input->options() as $value => $display_text) {
         $option_value_as_string = $this->_input->get_normalization_strategy()->unnormalize_one($value);
         $html_id = $multi ? $this->_input->html_id() . '-' . sanitize_key($option_value_as_string) : $this->_input->html_id();
         $html .= EEH_HTML::nl(0, 'checkbox');
         $html .= '<label for="' . $html_id . '" id="' . $html_id . '-lbl" class="ee-checkbox-label-after' . $label_size_class . '">';
         $html .= EEH_HTML::nl(1, 'checkbox');
         $html .= '<input type="checkbox"';
         $html .= ' name="' . $this->_input->html_name() . '[]"';
         $html .= ' id="' . $html_id . '"';
         $html .= ' class="' . $this->_input->html_class() . '"';
         $html .= ' style="' . $this->_input->html_style() . '"';
         $html .= ' value="' . esc_attr($value) . '"';
         $html .= !empty($input_raw_value) && in_array($value, $input_raw_value) ? ' checked="checked"' : '';
         $html .= '>&nbsp;';
         $html .= $display_text;
         $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>';
     }
     return $html;
 }
 /**
  * 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));
     }
 }
 /**
  * Used to register a new template pack with the messages system.
  *
  * Template packs are primarily defined via class extending EE_Messages_Template_Pack and are typically used to change entire layouts for a set of message templates.  This method is used to register the new template pack and automatically have it loaded in the appropriate places.
  *
  * This registry also verifies that there isn't already a template pack registered with the same name and if there is then it will add an EE_Error notice.
  *
  * Note that this only handles registering the your Template Pack class with the message template pack system.  However, there is also a naming schema you must follow for templates you are providing with your template pack.
  * @see EE_Messages_Template_Pack_Default for an example class
  * @see core/libraries/messages/defaults/default/* for all the example templates the default template pack supports.
  *
  *
  * @since  4.5.0
  * @throws EE_Error
  *
  * @param string $ref             The internal reference used to refer to this template pack.  Note, this is first come, first serve.  If there is already a template pack registered with this name then the registry will assign a unique reference for it so it can still be activated (but this makes it harder to deregister as it will be unique per load - so its best to try to make this a unique string!)
  * @param array  $setup_args array {
  *                           An array of required values for registering the template pack.
  *                           @type string $path 	The path for the new template pack class.
  *                           @type string $classname 	The name of the new Template Pack Class.
  * }
  *
  * @return void
  */
 public static function register($ref = NULL, $setup_args = array())
 {
     //check for required params
     if (empty($ref) || empty($setup_args['path']) || empty($setup_args['classname'])) {
         throw new EE_Error(__('In order to register a new template pack for the EE Messages system, you must include a value to reference the template pack being registered and the setup_args must have the path for the new template pack class as well as the classname for the new Template Pack Class. ', 'event_espresso'));
     }
     //make sure we don't register twice
     if (isset(self::$_registry[$ref])) {
         return;
     }
     //check that incoming $ref doesn't already exist. If it does then we'll create a unique reference for this template pack.
     if (isset(self::$_registry[$ref])) {
         $ref = uniqid() . '_' . $ref;
     }
     //make sure this was called in the right place!
     if (!did_action('EE_Brewing_Regular___messages_caf') || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')) {
         EE_Error::doing_it_wrong(__METHOD__, sprintf(__('A EE Messages Template Pack given the reference "%s" has been attempted to be registered with the EE Messages System.  It may or may not work because it should be only called on the "EE_Brewing_Regular__messages_caf" hook.', 'event_espresso'), $ref), '4.5.0');
     }
     if (self::_verify_class_not_exist($setup_args['classname'])) {
         self::$_registry[$ref] = array('path' => (string) $setup_args['path'], 'classname' => (string) $setup_args['classname']);
     }
     //hook into the system
     add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array('EE_Register_Messages_Template_Pack', 'set_template_pack_path'), 10);
     add_filter('FHEE__EED_Messages__get_template_packs__template_packs', array('EE_Register_Messages_Template_Pack', 'set_template_pack'), 10);
 }
 /**
  * Helper method for registring a new shortcodes library class for the messages system.
  *
  * Note this is not used for adding shortcodes to existing libraries.  It's for registering anything
  * related to registering a new EE_{shortcode_library_name}_Shortcodes.lib.php class.
  *
  * @since    4.3.0
  *
  * @param  array  $setup_args {
  *       An array of arguments provided for registering the new messages shortcode library.
  *
  *       @type string $name                                         What is the name of this shortcode library
  *                                                                              (e.g. 'question_list');
  *       @type array  $autoloadpaths                          An array of paths to add to the messages
  *                                                                              autoloader for the new shortcode library
  *                                                                              class file.
  *       @type string $msgr_validator_callback            Callback for a method that will register the
  *                                                                              library with the messenger
  *                                                                              _validator_config. Optional.
  *       @type string $msgr_template_fields_callback  Callback for changing adding the
  *                                                                              _template_fields property for messenger.
  *                                                                              For example, the shortcode library may add
  *                                                                              a new field to the message templates.
  *                                                                              Optional.
  *       @type string $valid_shortcodes_callback         Callback for message types
  *                                                                              _valid_shortcodes array setup. Optional.
  *       @type array  $list_type_shortcodes                 If there are any specific shortcodes with this
  *                                                                             message shortcode library that should be
  *                                                                             considered "list type" then include them in an
  *                                                                             array.  List Type shortcodes are shortcodes that
  *                                                                             have a corresponding field that indicates how
  *                                                                             they are parsed. Optional.
  * }
  * @return void
  */
 public static function register($name = NULL, $setup_args = array())
 {
     //required fields MUST be present, so let's make sure they are.
     if (empty($name) || !is_array($setup_args) || empty($setup_args['autoloadpaths'])) {
         throw new EE_Error(__('In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"', 'event_espresso'));
     }
     //make sure this was called in the right place!
     if (!did_action('EE_Brewing_Regular___messages_caf') || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')) {
         EE_Error::doing_it_wrong(__METHOD__, sprintf(__('Should be only called on the "EE_Brewing_Regular___messages_caf" hook (Trying to register a library named %s).', 'event_espresso'), $name), '4.3.0');
     }
     $name = (string) $name;
     self::$_ee_messages_shortcode_registry[$name] = array('autoloadpaths' => (array) $setup_args['autoloadpaths'], 'list_type_shortcodes' => !empty($setup_args['list_type_shortcodes']) ? (array) $setup_args['list_type_shortcodes'] : array());
     //add filters
     add_filter('FHEE__EE_Messages_Init__autoload_messages__dir_ref', array('EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'), 10);
     //add below filters if the required callback is provided.
     if (!empty($setup_args['msgr_validator_callback'])) {
         add_filter('FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2);
     }
     if (!empty($setup_args['msgr_template_fields_callback'])) {
         add_filter('FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2);
     }
     if (!empty($setup_args['valid_shortcodes_callback'])) {
         add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2);
     }
     if (!empty($setup_args['list_type_shortcodes'])) {
         add_filter('FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', array('EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'), 10);
     }
 }
 /**
  *    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);
     }
 }
 /**
  * Gets the default which is always the current user. This can't be set when initially
  * constructing the model field because that's done before $current_user is set
  * @return mixed
  */
 function get_default_value()
 {
     if (did_action('init')) {
         return get_current_user_id();
     } else {
         EE_Error::doing_it_wrong('EE_WP_User_Field::get_default_value', __('You cant get a default value for a wp_User_Field because the "init" action is called, because current_user global hasnt yet been setup. Consider doing your business logic on the "init" hook or later.', 'event_espresso'), '4.6.20');
         return 1;
     }
 }
 /**
  * @param string $model_id unique id for it
  * @param array  $config   {
  *		@type array $model_paths array of folders containing DB models, where each file follows the models naming convention,
  *                         which is: EEM_{model_name}.model.php which contains a single class called EEM_{model_name}. Eg. you could pass
  *                         "public_html/wp-content/plugins/my_addon/db_models" (with or without trailing slash) and in that folder put
  *                         each of your model files, like "EEM_Food.model.php" which contains the class "EEM_Food" and
  *                         "EEM_Monkey.model.php" which contains the class "EEM_Monkey". These will be autoloaded and added to
  *                         the EE registry so they can be used like ordinary models. The class contained in each file should extend EEM_Base.
  *		@type array $class_paths array of folders containing DB classes, where each file follows the model class naming convention,
  *                         which is EE_{model_name}.class.php. The class contained in each file should extend EE_Base_Class
  *
  * }
  * @throws EE_Error
  */
 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_paths'])) {
         throw new EE_Error(__('In order to register Models with EE_Register_Model::register(), you must include a "model_id" (a unique identifier for this set of models), and an array containing the following keys: "model_paths" (an array of full server paths to folders that contain models)', 'event_espresso'));
     }
     //make sure we don't register twice
     if (isset(self::$_model_registry[$model_id])) {
         return;
     }
     if (!did_action('AHEE__EE_System__load_espresso_addons') || did_action('FHEE__EE_System__parse_model_names') || did_action('FHEE__EE_System__parse_implemented_model_names')) {
         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.5');
     }
     self::$_model_registry[$model_id] = $config;
     EE_Registry::instance()->load_helper('File');
     if (isset($config['model_paths']) && !isset($config['class_paths']) || !isset($config['model_paths']) && isset($config['class_paths'])) {
         throw new EE_Error(sprintf(__('You must register both "model_paths" AND "class_paths", not just one or the other You provided %s', 'event_espresso'), implode(", ", array_keys($config))));
     }
     if (isset($config['model_paths'])) {
         //make sure they passed in an array
         if (!is_array($config['model_paths'])) {
             $config['model_paths'] = array($config['model_paths']);
         }
         //we want to add this as a model folder
         //and autoload them all
         $class_to_filepath_map = EEH_File::get_contents_of_folders($config['model_paths']);
         EEH_Autoloader::register_autoloader($class_to_filepath_map);
         $model_name_to_classname_map = array();
         foreach (array_keys($class_to_filepath_map) as $classname) {
             $model_name_to_classname_map[str_replace("EEM_", "", $classname)] = $classname;
         }
         self::$_model_name_to_classname_map[$model_id] = $model_name_to_classname_map;
         add_filter('FHEE__EE_System__parse_model_names', array('EE_Register_Model', 'add_addon_models'));
         add_filter('FHEE__EE_System__parse_implemented_model_names', array('EE_Register_Model', 'add_addon_models'));
         add_filter('FHEE__EE_Registry__load_model__paths', array('EE_Register_Model', 'add_model_folders'));
         unset($config['model_paths']);
     }
     if (isset($config['class_paths'])) {
         //make sure they passed in an array
         if (!is_array($config['class_paths'])) {
             $config['class_paths'] = array($config['class_paths']);
         }
         $class_to_filepath_map = EEH_File::get_contents_of_folders($config['class_paths']);
         EEH_Autoloader::register_autoloader($class_to_filepath_map);
         add_filter('FHEE__EE_Registry__load_class__paths', array('EE_Register_Model', 'add_class_folders'));
         unset($config['class_paths']);
     }
     foreach ($config as $unknown_key => $unknown_config) {
         self::deregister($model_id);
         throw new EE_Error(sprintf(__("The key '%s' is not a known key for registering a model", "event_espresso"), $unknown_key));
     }
 }
 /**
  *    Method for registering new Data Migration Scripts
  *
  * @since    4.3.0
  * @param string $dms_id		a unique identifier for this set of data migration scripts
  * @param  array $setup_args  						An array of arguments provided for registering the data migration scripts
  * @internal param string dms_paths 				an array of full server paths to folders that contain data migration scripts
  * @throws EE_Error
  * @return void
  */
 public static function register($dms_id = NULL, $setup_args = array())
 {
     //required fields MUST be present, so let's make sure they are.
     if (empty($dms_id) || !is_array($setup_args) || empty($setup_args['dms_paths'])) {
         throw new EE_Error(__('In order to register Data Migration Scripts with EE_Register_Data_Migration_Scripts::register(), you must include a "dms_id" (a unique identifier for this set of data migration scripts), and  an array containing the following keys: "dms_paths" (an array of full server paths to folders that contain data migration scripts)', 'event_espresso'));
     }
     //make sure this was called in the right place!
     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__, __('An attempt to register Data Migration Scripts has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register Data Migration Scripts.', 'event_espresso'), '4.3.0');
     }
     //setup $_settings array from incoming values.
     self::$_settings[$dms_id] = array('dms_paths' => isset($setup_args['dms_paths']) ? (array) $setup_args['dms_paths'] : array());
     // setup DMS
     add_filter('FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', array('EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders'));
 }
 /**
  *    Method for registering new EED_Widgets
  *
  * @since    4.3.0
  * @param string $widget_id			a unique identifier for this set of widgets
  * @param  array $setup_args  		an array of arguments provided for registering widgets
  * @internal param string widget_paths 		an array of full server paths to folders containing any EED_Widgets, or to the EED_Widget files themselves
  * @throws EE_Error
  * @return void
  */
 public static function register($widget_id = NULL, $setup_args = array())
 {
     //required fields MUST be present, so let's make sure they are.
     if (empty($widget_id) || !is_array($setup_args) || empty($setup_args['widget_paths'])) {
         throw new EE_Error(__('In order to register Widgets with EE_Register_Widget::register(), you must include a "widget_id" (a unique identifier for this set of widgets), and an array containing the following keys: "widget_paths" (an array of full server paths to folders that contain widgets, or to the widget files themselves)', 'event_espresso'));
     }
     //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 widgets 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 widgets.', 'event_espresso'), '4.3.0');
     }
     //setup $_settings array from incoming values.
     self::$_settings[$widget_id] = array('widget_paths' => isset($setup_args['widget_paths']) ? (array) $setup_args['widget_paths'] : array());
     // add to list of widgets to be registered
     add_filter('FHEE__EE_Config__register_widgets__widgets_to_register', array('EE_Register_Widget', 'add_widgets'));
 }
 /**
  * Handles registering the new config with the EE_Config::instance()->addons property
  *
  * @since    4.3.0
  * @throws EE_Error
  *
  * @param  string $config_class 	The name of the Config class being registered.
  *                                   					Note this class must extend EE_Config Base and must have already been registered with an autoloader.
  * @param  array $setup_args {
  *
  * 		@type  string $config_name 	Optional.  by default the new config will be registered to EE_Config::instance()->addons->{config_class}, but supplying a "config_name" will set the property name that this variable is accessible by. ie: EE_Config::instance()->addons->{config_name}
  *                       		}
  * @return void
  */
 public static function register($config_class = NULL, $setup_args = array())
 {
     $setup_args['config_name'] = isset($setup_args['config_name']) && !empty($setup_args['config_name']) ? $setup_args['config_name'] : $config_class;
     $setup_args['config_section'] = isset($setup_args['config_section']) && !empty($setup_args['config_section']) ? $setup_args['config_section'] : 'addons';
     //required fields MUST be present, so let's make sure they are.
     if (empty($config_class) || !is_array($setup_args) || empty($setup_args['config_name'])) {
         throw new EE_Error(__('In order to register a Config Class with EE_Register_Config::register(), you must include a "config_class" (the actual class name for this config class). As well, you can supply an array containing the following keys: "config_section" the main section of the config object the settings will be saved under (by default the new config will be registered under EE_Config::instance()->modules or EE_Config::instance()->addons depending on what type of class is calling this), "config_name" (by default the new config will be registered to EE_Config::instance()->{config_section}->{config_class}, but supplying a "config_name" will set the property name that this variable is accessible by. ie: EE_Config::instance()->{config_section}->{config_name})', 'event_espresso'));
     }
     //first find out if this happened too late.
     if (did_action('AHEE__EE_System__load_core_configuration__begin')) {
         EE_Error::doing_it_wrong(__METHOD__, sprintf(__('An attempt to register "%s" as an EE_Config object has failed because it was not registered at the correct hookpoint.  Please register before the "AHEE__EE_System__load_core_configuration__begin" hook has fired', 'event_espresso'), $setup_args['config_name']), '4.3');
     }
     //add incoming stuff to our registry property
     self::$_ee_config_registry[$config_class] = array('section' => $setup_args['config_section'], 'name' => $setup_args['config_name']);
     add_filter('AHEE__EE_Config___load_core_config__end', array('EE_Register_Config', 'set_config'), 10);
 }
 /**
  * Method for registering new message types in the EE_messages system.
  *
  * Note:  All message types must have the following files in order to work:
  *
  * - EE_Message_Template_Defaults extended class(es). (see /core/libraries/messages/defaults
  *     for examples).  Note, how there is a default class for each messenger/messagetype combo.
  *     This class is used for defining how the default templates get setup.
  * - Template files for default templates getting setup (or you can define it all in the above
  *      Default class).  See /core/libraries/messages/message_type/assets/defaults/ for examples.
  * - EE_Messages_Validator extended class(es).  See /core/libraries/messages/validators/email/
  *      for examples.  Note for any new message types, there will need to be a validator for each
  *      messenger combo this message type can activate with.
  * - And of course the main EE_{Message_Type_Name}_message_type class that defines the new
  *      message type and its properties.
  *
  * @since   4.3.0
  *
  * 	@param string $mt_name                               Whatever is defined for the $name property of
  *                                                                          the message type you are registering (eg.
  *                                                                          declined_registration). Required.
  * @param  array  $setup_args  {
  *        An array of arguments provided for registering the message type.
  *
  *        @type string $mtfilename                          The filename of the message type being
  *                                                                          registered.  This will be the main
  *                                                                          EE_{Messagetype_Name}_message_type class. (
  *                                                                          eg. EE_Declined_Registration_message_type.
  *                                                                          class.php). Required.
  *        @type array $autoloadpaths                       An array of paths to add to the messages
  *                                                                          autoloader for the new message type. Required.
  *        @type array $messengers_to_activate_with An array of messengers that this message
  *                                                                          type should activate with. Each value in the
  *                                                                          array should match the name property of a
  *                                                                          EE_messenger. Optional.
  *
  * }
  * @return void
  */
 public static function register($mt_name = NULL, $setup_args = array())
 {
     //required fields MUST be present, so let's make sure they are.
     if (!isset($mt_name) || !is_array($setup_args) || empty($setup_args['mtfilename']) || empty($setup_args['autoloadpaths'])) {
         throw new EE_Error(__('In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"', 'event_espresso'));
     }
     //make sure this was called in the right place!
     if (!did_action('EE_Brewing_Regular___messages_caf') || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')) {
         EE_Error::doing_it_wrong(__METHOD__, sprintf(__('A message type named "%s" has been attempted to be registered with the EE Messages System.  It may or may not work because it should be only called on the "EE_Brewing_Regular___messages_caf" hook.', 'event_espresso'), $mt_name), '4.3.0');
     }
     //setup $__ee_message_type_registry array from incoming values.
     self::$_ee_message_type_registry[$mt_name] = array('mtfilename' => (string) $setup_args['mtfilename'], 'autoloadpaths' => (array) $setup_args['autoloadpaths'], 'messengers_to_activate_with' => !empty($setup_args['messengers_to_activate_with']) ? (array) $setup_args['messengers_to_activate_with'] : array());
     //add filters
     add_filter('FHEE__EE_Messages_Init__autoload_messages__dir_ref', array('EE_Register_Message_Type', 'register_msgs_autoload_paths'), 10);
     add_filter('FHEE__EE_messages__get_installed__messagetype_files', array('EE_Register_Message_Type', 'register_messagetype_files'), 10, 1);
     add_filter('FHEE__EE_messenger__get_default_message_types__default_types', array('EE_Register_Message_Type', 'register_messengers_to_activate_mt_with'), 10, 2);
 }
 /**
  * 		@Constructor
  * 		@access public
  * 		@return void
  */
 public function __construct()
 {
     //set global defaults
     $this->_set_defaults();
     //set properties that are always available with objects.
     $this->_set_init_properties();
     //global styles/scripts across all wp admin pages
     add_action('admin_enqueue_scripts', array($this, 'load_wp_global_scripts_styles'), 5);
     //load initial stuff.
     $this->_set_file_and_folder_name();
     $this->_set_menu_map();
     if (empty($this->_menu_map) || is_array($this->_menu_map)) {
         EE_Error::doing_it_wrong(get_class($this) . '::$_menu_map', sprintf(__('The EE4 addon with the class %s is setting up the _menu_map property incorrectly for this version of EE core.  Please see Admin_Page_Init class examples in core for the new way of setting this property up.', 'event_espresso'), get_class($this)), '4.4.0');
         return;
     }
     //set default capability
     $this->_set_capability();
 }
 /**
  * The purpose of this method is to provide an easy way for addons to register their admin pages (using the EE Admin Page loader system).
  *
  * @since 4.3.0
  *
  * @param  string $page_basename 	This string represents the basename of the Admin Page init.
  *                                                        		The init file must use this basename in its name and class (i.e. {page_basename}_Admin_Page_Init.core.php).
  * @param  array  $config  {              An array of configuration options that will be used in different circumstances
  *
  *		@type  string $page_path             This is the path where the registered admin pages reside ( used to setup autoloaders).
  *
  * 	}
  * @return void
  */
 public static function register($page_basename = NULL, $config = array())
 {
     // check that an admin_page has not already been registered with that name
     if (isset(self::$_ee_admin_page_registry[$page_basename])) {
         throw new EE_Error(sprintf(__('An Admin Page with the name "%s" has already been registered and each Admin Page requires a unique name.', 'event_espresso'), $page_basename));
     }
     // required fields MUST be present, so let's make sure they are.
     if (empty($page_basename) || !is_array($config) || empty($config['page_path'])) {
         throw new EE_Error(__('In order to register an Admin Page with EE_Register_Admin_Page::register(), you must include the "page_basename" (the class name of the page), and an array containing the following keys: "page_path" (the path where the registered admin pages reside)', 'event_espresso'));
     }
     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 an EE Admin page has failed because it was not registered at the correct time.  Please use the "AHEE__EE_Admin__loaded" hook to register Admin pages.', 'event_espresso'), $page_basename), '4.3');
     }
     //add incoming stuff to our registry property
     self::$_ee_admin_page_registry[$page_basename] = array('page_path' => $config['page_path'], 'config' => $config);
     //add filters
     add_filter('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', array('EE_Register_Admin_Page', 'set_page_basename'), 10);
     add_filter('FHEE__EEH_Autoloader__load_admin_core', array('EE_Register_Admin_Page', 'set_page_path'), 10);
 }
 /**
  * Used to register a new promotion scope with the EE Promotions addon.
  *
  * @since 1.0.0
  * @throws EE_Error
  *
  * @param string $promotion_id  	A unique ID for this promotion scope.
  * @param array  $config 		array {
  *                         A configuration array in the format:
  *                         @type string $scope_path	A full server path to the EE_Promotion_Scope
  *                               				child class being registered. Required.
  *                         @type array $model_extension_paths	@see EE_Register_Model_Extensions
  *                         @type array $class_extension_paths		@see EE_Register_Model_Extensions
  * }
  *
  * @return void
  */
 public static function register($promotion_id = NULL, $config = array())
 {
     //required fields must be present, so let's make sure they are.
     if (empty($promotion_id)) {
         throw new EE_Error(__('Any client code calling EE_Register_Promotion_Scope must set a unique string for the $promotion_id argument.  None was given.', 'event_espresso'));
     }
     if (!is_array($config) || empty($config['scope_path']) || empty($config['model_extension_paths']) || empty($config['class_extension_paths'])) {
         throw new EE_Error(__('In order to register a new promotion scope via EE_Register_Promotion_Scope, the caller must include an array for the configuration that contains the follow keys: "scope_path" (a string containing the full server path to the child class extending EE_Promotion_Scope), "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
     //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 promotion scope has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook at a priority level higher than 5, to register promotion scopes.', 'event_espresso'), $promotion_id), '1.0.0');
     }
     //set config to registry
     self::$_registry[$promotion_id] = $config;
     //add new scope path to scopes loader
     add_filter('FHEE__EE_Promotions_Config___get_scopes__scopes_to_register', array('EE_Register_Promotion_Scope', 'register_path'));
     //use EE_Register_Model_Extensions with the config.
     unset($config['scope_path']);
     EE_Register_Model_Extensions::register($promotion_id, $config);
 }
 /**
  * @deprecated
  * @since 4.7.0
  * @return string
  */
 public function pretty_price_paid()
 {
     EE_Error::doing_it_wrong('EE_Registration::pretty_price_paid()', __('This method is deprecated, please use EE_Registration::pretty_final_price() instead.', 'event_espresso'), '4.7.0');
     return $this->pretty_final_price();
 }
 public function save_csv_to_db($csv_data_array, $model_name = FALSE)
 {
     EE_Error::doing_it_wrong('save_csv_to_db', __('Function moved to EE_Import and renamed to save_csv_data_array_to_db', 'event_espresso'), '4.6.7');
     return EE_Import::instance()->save_csv_data_array_to_db($csv_data_array, $model_name);
 }
Ejemplo n.º 19
0
 /**
  * static method for registering ee admin page.
  *
  * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.
  *
  * @since      4.3.0
  * @deprecated 4.3.0    Use EE_Register_Admin_Page::register() instead
  * @see        EE_Register_Admin_Page::register()
  *
  * @param       $page_basename
  * @param       $page_path
  * @param array $config
  * @return void
  */
 public static function register_ee_admin_page($page_basename, $page_path, $config = array())
 {
     EE_Error::doing_it_wrong(__METHOD__, sprintf(__('Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3');
     if (class_exists('EE_Register_Admin_Page')) {
         $config['page_path'] = $page_path;
     }
     EE_Register_Admin_Page::register($page_basename, $config);
 }
/**
 * can_use_espresso_conditionals
 * tests whether the Espresso Conditional tags like is_espresso_event_single() can be called
 *
 * @param $conditional_tag
 * @return bool
 */
function can_use_espresso_conditionals($conditional_tag)
{
    if (!did_action('AHEE__EE_System__initialize')) {
        EE_Error::doing_it_wrong(__FUNCTION__, sprintf(__('The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', 'event_espresso'), $conditional_tag), '4.4.0');
        return FALSE;
    }
    return TRUE;
}
 /**
  * 	add success message
  *
  *	@access public
  * 	@param		string		$type	whether the message is for a success or error notification
  * 	@param		string		$msg	the message to display to users or developers - adding a double pipe || (OR) creates separate messages for user || dev
  * 	@param		string		$file		the file that the error occurred in - just use __FILE__
  * 	@param		string		$func	the function/method that the error occurred in - just use __FUNCTION__
  * 	@param		string		$line	the line number where the error occurred - just use __LINE__
  * 	@return 		void
  */
 private static function _add_notice($type = 'success', $msg = NULL, $file = NULL, $func = NULL, $line = NULL)
 {
     if (empty($msg)) {
         EE_Error::doing_it_wrong('EE_Error::add_' . $type . '()', sprintf(__('Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', 'event_espresso'), $type, $file, $line), EVENT_ESPRESSO_VERSION);
     }
     if ($type == 'errors' && (empty($file) || empty($func) || empty($line))) {
         EE_Error::doing_it_wrong('EE_Error::add_error()', __('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', 'event_espresso'), EVENT_ESPRESSO_VERSION);
     }
     // get separate user and developer messages if they exist
     $msg = explode('||', $msg);
     $user_msg = $msg[0];
     $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
     $msg = WP_DEBUG ? $dev_msg : $user_msg;
     // add notice if message exists
     if (!empty($msg)) {
         // get error code
         $notice_code = EE_Error::generate_error_code($file, $func, $line);
         if (WP_DEBUG && $type == 'errors') {
             $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>';
         }
         // add notice. Index by code if it's not blank
         if ($notice_code) {
             self::$_espresso_notices[$type][$notice_code] = $msg;
         } else {
             self::$_espresso_notices[$type][] = $msg;
         }
         add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1);
     }
 }
 /**
  *    Method for registering new EE_Addons.
  * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components.
  * However, it may also be called after the 'activate_plugin' action (when an addon is activated),
  * because an activating addon won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired.
  * If its called after 'activate_plugin', it registers the addon still, but its components are not registered
  * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns
  * (so that we can detect that the addon has activated on the subsequent request)
  *
  * @since    4.3.0
  * @param string $addon_name 		the EE_Addon's name. Required.
  * @param  array $setup_args { 			An array of arguments provided for registering the message type.
  * @type  string $class_name the addon's main file name. If left blank, generated from the addon name, changes something like "calendar" to "EE_Calendar"
  *			@type string $min_core_version  the minimum version of EE Core that the addon will work with. eg "4.8.1.rc.084"
  *			@type string $version the "software" version for the addon. eg "1.0.0.p" for a first stable release, or "1.0.0.rc.043" for a version in progress
  *			@type string $main_file_path the full server path to the main file loaded directly by WP
  *          @type string $admin_path 	full server path to the folder where the addon\'s admin files reside
  *			@type string $admin_callback a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page
  *			@type string $config_section the section name for this addon's configuration settings section (defaults to "addons")
  *			@type string $config_class the class name for this addon's configuration settings object
  *			@type string $config_name the class name for this addon's configuration settings object
  * 			@type string $autoloader_paths an array of class names and the full server paths to those files. Required.
  *			@type string $autoloader_folders  an array of  "full server paths" for any folders containing classes that might be invoked by the addon
  * 			@type string $dms_paths 				an array of full server paths to folders that contain data migration scripts. Required.
  * 			@type string $module_paths 	an array of full server paths to any EED_Modules used by the addon
  * 			@type string $shortcode_paths 	an array of full server paths to folders that contain EES_Shortcodes
  * 			@type string $widget_paths 					an array of full server paths to folders that contain WP_Widgets
  *			@type string $pue_options
  * 			@type array $capabilities  {
  * 			      	an array indexed by role name (i.e. administrator,author ) and the values are an array of caps to add to the role.
  * 			      	'administrator' => array('read_addon', 'edit_addon' etc.).
  * 	         		}
  * 	        @type EE_Meta_Capability_Map[] $capability_maps an array of EE_Meta_Capability_Map object for any addons that need to register any special meta mapped capabilities.  Should be indexed where the key is the EE_Meta_Capability_Map class name and the values are the arguments sent to the class.
  *			@type array $model_paths array of folders containing DB models @see EE_Register_Model
  *			@type array $class_paths array of folders containing DB classes @see EE_Register_Model
  *			@type array $model_extension_paths array of folders containing DB model extensions @see EE_Register_Model_Extension
  *			@type array $class_extension_paths array of folders containing DB class extensions @see EE_Register_Model_Extension
  * 			@type array message_types {
  *       		 An array of message types with the key as the message type name and the values as below:
  *        		@type string $mtfilename The filename of the message type being registered.  This will be the main
  *                                       EE_{Messagetype_Name}_message_type class. (eg. EE_Declined_Registration_message_type.class.php). Required.
  *               @type array $autoloadpaths An array of paths to add to the messages autoloader for the new message type. Required.
  *               @type array $messengers_to_activate_with An array of messengers that this message
  *                           type should activate with. Each value in the array should match the name property of a EE_messenger. Optional.
  *               @type array $messengers_to_validate_with An array of messengers that this message
  *                          type should validate with. Each value in the array should match the name property of an EE_messenger. Optional.
  *       	}
  *			@type array $custom_post_types
  *			@type array $custom_taxonomies
  *			@type array $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)
  *			@type array $default_terms
  * 	}
  *
  * @throws EE_Error
  * @return void
  */
 public static function register($addon_name = '', $setup_args = array())
 {
     // required fields MUST be present, so let's make sure they are.
     if (empty($addon_name) || !is_array($setup_args)) {
         throw new EE_Error(__('In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', 'event_espresso'));
     }
     if (!isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
         throw new EE_Error(sprintf(__('When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', 'event_espresso'), implode(",", array_keys($setup_args))));
     }
     // check that addon has not already been registered with that name
     if (isset(self::$_settings[$addon_name]) && !did_action('activate_plugin')) {
         throw new EE_Error(sprintf(__('An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', 'event_espresso'), $addon_name));
     }
     // no class name for addon?
     if (empty($setup_args['class_name'])) {
         // generate one by first separating name with spaces
         $class_name = str_replace(array('-', '_'), ' ', trim($addon_name));
         //capitalize, then replace spaces with underscores
         $class_name = str_replace(' ', '_', ucwords($class_name));
     } else {
         $class_name = $setup_args['class_name'];
     }
     $class_name = strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_' . $class_name;
     //setup $_settings array from incoming values.
     $addon_settings = array('class_name' => $class_name, 'plugin_slug' => isset($setup_args['plugin_slug']) ? (string) $setup_args['plugin_slug'] : '', 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) ? (string) $setup_args['plugin_action_slug'] : '', 'version' => isset($setup_args['version']) ? (string) $setup_args['version'] : '', 'min_core_version' => isset($setup_args['min_core_version']) ? (string) $setup_args['min_core_version'] : '', 'main_file_path' => isset($setup_args['main_file_path']) ? (string) $setup_args['main_file_path'] : '', 'admin_path' => isset($setup_args['admin_path']) ? (string) $setup_args['admin_path'] : '', 'admin_callback' => isset($setup_args['admin_callback']) ? (string) $setup_args['admin_callback'] : '', 'config_section' => isset($setup_args['config_section']) ? (string) $setup_args['config_section'] : 'addons', 'config_class' => isset($setup_args['config_class']) ? (string) $setup_args['config_class'] : '', 'config_name' => isset($setup_args['config_name']) ? (string) $setup_args['config_name'] : '', 'autoloader_paths' => isset($setup_args['autoloader_paths']) ? (array) $setup_args['autoloader_paths'] : array(), 'autoloader_folders' => isset($setup_args['autoloader_folders']) ? (array) $setup_args['autoloader_folders'] : array(), 'dms_paths' => isset($setup_args['dms_paths']) ? (array) $setup_args['dms_paths'] : array(), 'module_paths' => isset($setup_args['module_paths']) ? (array) $setup_args['module_paths'] : array(), 'shortcode_paths' => isset($setup_args['shortcode_paths']) ? (array) $setup_args['shortcode_paths'] : array(), 'widget_paths' => isset($setup_args['widget_paths']) ? (array) $setup_args['widget_paths'] : array(), 'pue_options' => isset($setup_args['pue_options']) ? (array) $setup_args['pue_options'] : array(), 'message_types' => isset($setup_args['message_types']) ? (array) $setup_args['message_types'] : array(), 'capabilities' => isset($setup_args['capabilities']) ? (array) $setup_args['capabilities'] : array(), 'capability_maps' => isset($setup_args['capability_maps']) ? (array) $setup_args['capability_maps'] : array(), 'model_paths' => isset($setup_args['model_paths']) ? (array) $setup_args['model_paths'] : array(), 'class_paths' => isset($setup_args['class_paths']) ? (array) $setup_args['class_paths'] : array(), 'model_extension_paths' => isset($setup_args['model_extension_paths']) ? (array) $setup_args['model_extension_paths'] : array(), 'class_extension_paths' => isset($setup_args['class_extension_paths']) ? (array) $setup_args['class_extension_paths'] : array(), 'custom_post_types' => isset($setup_args['custom_post_types']) ? (array) $setup_args['custom_post_types'] : array(), 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) ? (array) $setup_args['custom_taxonomies'] : array(), 'payment_method_paths' => isset($setup_args['payment_method_paths']) ? (array) $setup_args['payment_method_paths'] : array(), 'default_terms' => isset($setup_args['default_terms']) ? (array) $setup_args['default_terms'] : array(), 'plugins_page_row' => isset($setup_args['plugins_page_row']) ? $setup_args['plugins_page_row'] : '');
     // if plugin_action_slug is NOT set, but an admin page path IS set, then let's just use the plugin_slug since that will be used for linking to the admin page
     $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug']) && !empty($addon_settings['admin_path']) ? $addon_settings['plugin_slug'] : $addon_settings['plugin_action_slug'];
     // full server path to main file (file loaded directly by WP)
     $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']);
     //check whether this addon version is compatible with EE core
     if (isset(EE_Register_Addon::$_incompatible_addons[$addon_name]) && !self::_meets_min_core_version_requirement(EE_Register_Addon::$_incompatible_addons[$addon_name], $addon_settings['version'])) {
         $incompatibility_message = sprintf(__('The Event Espresso "%1$s" addon was deactivated because it is incompatible with this version of core.%2$s Only version %3$s or higher of "%1$s" can run with this version of core. This can happen when attempting to run beta versions or release candidates with older versions of core, or running old versions of addons with a newer version of core.%2$sPlease upgrade Event Espresso Core and the "%1$s" addon, then re-attempt activating it.', 'event_espresso'), $addon_name, '<br />', EE_Register_Addon::$_incompatible_addons[$addon_name]);
     } else {
         if (!self::_meets_min_core_version_requirement($setup_args['min_core_version'], espresso_version())) {
             $incompatibility_message = sprintf(__('The Event Espresso "%1$s" addon could not be activated because it requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-attempt activating "%1$s".', 'event_espresso'), $addon_name, self::_effective_version($setup_args['min_core_version']), self::_effective_version(espresso_version()), '<br />');
         } else {
             $incompatibility_message = '';
         }
     }
     if (!empty($incompatibility_message)) {
         //remove 'activate' from the REQUEST so WP doesn't erroneously tell the user the
         //plugin activated fine when it didn't
         if (isset($_GET['activate'])) {
             unset($_GET['activate']);
         }
         if (isset($_REQUEST['activate'])) {
             unset($_REQUEST['activate']);
         }
         //and show an error message indicating the plugin didn't activate properly
         EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__);
         if (current_user_can('activate_plugins')) {
             require_once ABSPATH . 'wp-admin/includes/plugin.php';
             deactivate_plugins(plugin_basename($addon_settings['main_file_path']), TRUE);
         }
         return;
     }
     //this is an activation request
     if (did_action('activate_plugin')) {
         //to find if THIS is the addon that was activated,
         //just check if we have already registered it or not
         //(as the newly-activated addon wasn't around the first time addons were registered)
         if (!isset(self::$_settings[$addon_name])) {
             self::$_settings[$addon_name] = $addon_settings;
             $addon = self::_load_and_init_addon_class($addon_name);
             $addon->set_activation_indicator_option();
             //dont bother setting up the rest of the addon.
             //we know it was just activated and the request will end soon
         }
         return;
     } else {
         // make sure this was called in the right place!
         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(__('An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.', 'event_espresso'), $addon_name), '4.3.0');
         }
         self::$_settings[$addon_name] = $addon_settings;
     }
     // we need cars
     if (!empty(self::$_settings[$addon_name]['autoloader_paths'])) {
         // setup autoloader for single file
         EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']);
     }
     // setup autoloaders for folders
     if (!empty(self::$_settings[$addon_name]['autoloader_folders'])) {
         foreach (self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) {
             EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
         }
     }
     // register new models
     if (!empty(self::$_settings[$addon_name]['model_paths']) || !empty(self::$_settings[$addon_name]['class_paths'])) {
         EE_Register_Model::register($addon_name, array('model_paths' => self::$_settings[$addon_name]['model_paths'], 'class_paths' => self::$_settings[$addon_name]['class_paths']));
     }
     // register model extensions
     if (!empty(self::$_settings[$addon_name]['model_extension_paths']) || !empty(self::$_settings[$addon_name]['class_extension_paths'])) {
         EE_Register_Model_Extensions::register($addon_name, array('model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'], 'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths']));
     }
     // setup DMS
     if (!empty(self::$_settings[$addon_name]['dms_paths'])) {
         EE_Register_Data_Migration_Scripts::register($addon_name, array('dms_paths' => self::$_settings[$addon_name]['dms_paths']));
     }
     // if config_class is present let's register config.
     if (!empty(self::$_settings[$addon_name]['config_class'])) {
         EE_Register_Config::register(self::$_settings[$addon_name]['config_class'], array('config_section' => self::$_settings[$addon_name]['config_section'], 'config_name' => self::$_settings[$addon_name]['config_name']));
     }
     // register admin page
     if (!empty(self::$_settings[$addon_name]['admin_path'])) {
         EE_Register_Admin_Page::register($addon_name, array('page_path' => self::$_settings[$addon_name]['admin_path']));
     }
     // add to list of modules to be registered
     if (!empty(self::$_settings[$addon_name]['module_paths'])) {
         EE_Register_Module::register($addon_name, array('module_paths' => self::$_settings[$addon_name]['module_paths']));
     }
     // add to list of shortcodes to be registered
     if (!empty(self::$_settings[$addon_name]['shortcode_paths'])) {
         EE_Register_Shortcode::register($addon_name, array('shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths']));
     }
     // add to list of widgets to be registered
     if (!empty(self::$_settings[$addon_name]['widget_paths'])) {
         EE_Register_Widget::register($addon_name, array('widget_paths' => self::$_settings[$addon_name]['widget_paths']));
     }
     //register capability related stuff.
     if (!empty(self::$_settings[$addon_name]['capabilities'])) {
         EE_Register_Capabilities::register($addon_name, array('capabilities' => self::$_settings[$addon_name]['capabilities'], 'capability_maps' => self::$_settings[$addon_name]['capability_maps']));
     }
     //any message type to register?
     if (!empty(self::$_settings[$addon_name]['message_types'])) {
         add_action('EE_Brewing_Regular___messages_caf', array('EE_Register_Addon', 'register_message_types'));
     }
     // if plugin update engine is being used for auto-updates (not needed if PUE is not being used)
     if (!empty($setup_args['pue_options'])) {
         self::$_settings[$addon_name]['pue_options'] = array('pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) ? (string) $setup_args['pue_options']['pue_plugin_slug'] : 'espresso_' . strtolower($class_name), 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) ? (string) $setup_args['pue_options']['plugin_basename'] : plugin_basename(self::$_settings[$addon_name]['main_file_path']), 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) ? (string) $setup_args['pue_options']['checkPeriod'] : '24', 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) ? (string) $setup_args['pue_options']['use_wp_update'] : FALSE);
         add_action('AHEE__EE_System__brew_espresso__after_pue_init', array('EE_Register_Addon', 'load_pue_update'));
     }
     //any custom post type/ custom capabilities or default terms to register
     if (!empty(self::$_settings[$addon_name]['custom_post_types']) || !empty(self::$_settings[$addon_name]['custom_taxonomies'])) {
         EE_Register_CPT::register($addon_name, array('cpts' => self::$_settings[$addon_name]['custom_post_types'], 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], 'default_terms' => self::$_settings[$addon_name]['default_terms']));
     }
     if (!empty(self::$_settings[$addon_name]['payment_method_paths'])) {
         EE_Register_Payment_Method::register($addon_name, array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths']));
     }
     // load and instantiate main addon class
     $addon = self::_load_and_init_addon_class($addon_name);
     // call any additional admin_callback functions during load_admin_controller hook
     if (!empty(self::$_settings[$addon_name]['admin_callback'])) {
         add_action('AHEE__EE_System__load_controllers__load_admin_controllers', array($addon, self::$_settings[$addon_name]['admin_callback']));
     }
 }
 /**
  * Updates the transaction's status and total_paid based on all the payments
  * that apply to it
  * @deprecated
  * @return boolean
  */
 public function update_based_on_payments()
 {
     EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'), '4.6.0');
     /** @type EE_Transaction_Processor $transaction_processor */
     $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
     return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($this);
 }
    /**
     * form_form_field_input__wrap
     *
     * @deprecated    as of 4.8.32.rc.000
     * @access        public
     * @param        string $input
     * @return        string
     */
    public function form_form_field_input__wrap($input)
    {
        EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, __('This method would have been protected but was used on a filter callback' . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), '4.8.32.rc.000');
        return '
				<td class="reg-admin-attendee-questions-input-td disabled-input">
					' . $input . '
				</td>
			</tr>';
    }
 /**
  * This is identical to EE_Model_Relation->get_all_related() except we're going handle special autosave conditions in here.
  * @param  EE_Base_Class|int  $model_object_or_id
  * @param  array   $query_params                            like EEM_Base::get_all's $query_params
  * @param  boolean $values_already_prepared_by_model_object @deprecated since 4.8.1
  * @return EE_Base_Class[]
  */
 public function get_all_related($model_object_or_id, $query_params = array(), $values_already_prepared_by_model_object = false)
 {
     if ($values_already_prepared_by_model_object !== false) {
         EE_Error::doing_it_wrong('EE_Model_Relation_Base::get_all_related', __('The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso'), '4.8.1');
     }
     //if this is an autosave then we're going to get things differently
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $this->_do_autosave_get_all($model_object_or_id, $query_params);
     }
     return parent::get_all_related($model_object_or_id, $query_params);
 }
Ejemplo n.º 26
0
 /**
  *
  * Returns the name of the activation indicator option
  * (an option which is set temporarily to indicate that this addon was just activated)
  * @deprecated since version 4.3.0.alpha.016
  * @return string
  */
 public function get_db_update_option_name()
 {
     EE_Error::doing_it_wrong(__FUNCTION__, __('EE_Addon::get_db_update_option was renamed to EE_Addon::get_activation_indicator_option_name', 'event_espresso'), '4.3.0.alpha.016');
     return $this->get_activation_indicator_option_name();
 }
 /**
  * Gets the first copy we find. See get_all_copies for more details
  * @param mixed EE_Base_Class | array        $model_object_or_attributes_array
  * @param array $query_params
  * @return EE_Base_Class
  */
 function get_one_copy($model_object_or_attributes_array, $query_params = array())
 {
     if (!is_array($query_params)) {
         EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
         $query_params = array();
     }
     $query_params['limit'] = 1;
     $copies = $this->get_all_copies($model_object_or_attributes_array, $query_params);
     if (is_array($copies)) {
         return array_shift($copies);
     } else {
         return null;
     }
 }
 /**
  * Returns the name of the paymetn method used on this payment (previously known merely as 'gateway')
  * but since 4.6.0, payment methods are models and the paymetn keeps a foreign key to the paymetn method
  * used on it
  * @deprecated
  * @return string
  */
 public function gateway()
 {
     EE_Error::doing_it_wrong('EE_Payment::gateway', __('The method EE_Payment::gateway() has been deprecated. Consider instead using EE_Payment::payment_method()->name()', 'event_espresso'), '4.6.0');
     if ($this->payment_method()) {
         return $this->payment_method()->name();
     } else {
         return __('Unknown', 'event_espresso');
     }
 }
 /**
  * 	@since 4.4.0
  */
 public static function _doing_it_wrong_notice($function = '')
 {
     EE_Error::doing_it_wrong(__FUNCTION__, sprintf(__('EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso'), $function, '<br />', '4.6.0'), '4.4.0');
 }
 /**
  * This simply registers the given qtip config and:
  * - adds it to the $_qtips property array.
  * - sets up the content containers for all qtips in the config,
  * - registers and enqueues the qtip scripts and styles.
  *
  * @access public
  * @param  array  $paths      Array of paths to check for the EE_Qtip class. If present we check these path(s) first.  If not present (empty array), then it's assumed it's either in core/libraries/qtips OR the file is already loaded.
  * @param  string|array $configname name of the Qtip class (full class name is expected and will be used for looking for file, Qtip config classes must extend EE_Qtip_Config) [if this is an array, then we loop through the array to instantiate and setup the qtips]
  * @return void
  */
 public function register($configname, $paths = array())
 {
     //let's just make sure this is instantiated in the right place.
     if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) {
         EE_Error::doing_it_wrong('EEH_Qtip_Loader->register()', __('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso'), '4.1');
     }
     $configname = (array) $configname;
     //typecast to array
     foreach ($configname as $config) {
         $this->_register($config, $paths);
     }
     //hook into appropriate footer
     $footer_action = is_admin() ? 'admin_footer' : 'wp_footer';
     add_action($footer_action, array($this, 'setup_qtip'), 10);
     //make sure we "turn on" qtip js.
     add_filter('FHEE_load_qtip', '__return_true');
 }