/** * when constructing a proper form section, calls _construct_finalize on children * so that they know who their parent is, and what name they've been given. * @param array $options_array { * @type $subsections EE_Form_Section_Validatable[] where keys are the section's name * @type $include string[] numerically-indexed where values are section names to be included, * and in that order. This is handy if you want * the subsections to be ordered differently than the default, and if you override which fields are shown * @type $exclude string[] values are subsections to be excluded. This is handy if you want * to remove certain default subsections (note: if you specify BOTH 'include' AND 'exclude', * the inclusions will be applied first, and the exclusions will exclude items from that list of inclusions) * @type $layout_strategy EE_Form_Section_Layout_Base strategy for laying out the form * } @see EE_Form_Section_Validatable::__construct() * */ public function __construct($options_array = array()) { EE_Registry::instance()->load_helper('Formatter'); //call parent first, as it may be setting the name parent::__construct($options_array); //if they've included subsections in the constructor, add them now if (isset($options_array['include'])) { //we are going to make sure we ONLY have those subsections to include //AND we are going to make sure they're in that specified order $reordered_subsections = array(); foreach ($options_array['include'] as $input_name) { if (isset($this->_subsections[$input_name])) { $reordered_subsections[$input_name] = $this->_subsections[$input_name]; } } $this->_subsections = $reordered_subsections; } if (isset($options_array['exclude'])) { $exclude = $options_array['exclude']; $this->_subsections = array_diff_key($this->_subsections, array_flip($exclude)); } if (isset($options_array['layout_strategy'])) { $this->_layout_strategy = $options_array['layout_strategy']; } if (!$this->_layout_strategy) { $this->_layout_strategy = new EE_Two_Column_Layout(); } $this->_layout_strategy->_construct_finalize($this); add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1); }
/** * This will just setup the _events property in the expected format. * @return void */ protected function _setup_data() { //now let's loop and set up the _events property. At the same time we'll set up attendee properties. //a variable for tracking totals $running_total = 0; //get txn $this->txn = $this->reg_obj->transaction(); $this->taxes = $this->txn->tax_total(); $this->grand_total_price_object = ''; //possible session stuff? $session = $this->txn->session_data(); $session_data = $session instanceof EE_Session ? $session->get_session_data() : array(); //other data from the session (if possible) $this->user_id = isset($session_data['user_id']) ? $session_data['user_id'] : ''; $this->ip_address = isset($session_data['ip_address']) ? $session_data['ip_address'] : ''; $this->user_agent = isset($session_data['user_agent']) ? $session_data['user_agent'] : ''; $this->init_access = $this->last_access = ''; $this->payment = $this->txn->get_first_related('Payment'); $this->payment = empty($this->payment) ? EE_Payment::new_instance(array('STS_ID' => EEM_Payment::status_id_pending, 'PAY_timestamp' => (int) current_time('timestamp'), 'PAY_gateway' => $this->txn->selected_gateway(), 'PAY_gateway_response' => $this->txn->gateway_response_on_transaction())) : $this->payment; //if there is no payments associated with the transaction then we just create a default payment object for potential parsing. $this->billing = $this->payment->details(); EE_Registry::instance()->load_helper('Template'); $this->billing['total_due'] = isset($this->billing['total']) ? EEH_Template::format_currency($this->billing['total']) : ''; //get reg_objs for txn $this->reg_objs = $this->txn->registrations(); //now we can set things up like we do for other handlers $this->_assemble_data(); }
/** * For adding any html output ab ove the payment overview. * Many gateways won't want ot display anything, so this function just returns an empty string. * Other gateways may want to override this, such as offline gateways. * @return string */ public function payment_overview_content(EE_Payment $payment) { EE_Registry::instance()->load_helper('Template'); $extra_meta_for_payment_method = $this->_pm_instance->all_extra_meta_array(); $template_vars = array_merge(array('payment_method' => $this->_pm_instance, 'payment' => $payment, 'page_title' => '', 'payment_instructions' => ''), $extra_meta_for_payment_method); return EEH_Template::locate_template('payment_methods' . DS . 'Bank' . DS . 'templates' . DS . 'bank_payment_details_content.template.php', $template_vars); }
/** * template_settings_form * * @access public * @static * @return void */ public static function template_settings_form() { $EE = EE_Registry::instance(); $EE->CFG->template_settings->EED_Event_Single = isset($EE->CFG->template_settings->EED_Event_Single) ? $EE->CFG->template_settings->EED_Event_Single : new EE_Event_Single_Config(); $EE->CFG->template_settings->EED_Event_Single = apply_filters('FHEE__EED_Event_Single__template_settings_form__event_list_config', $EE->CFG->template_settings->EED_Event_Single); EEH_Template::display_template(EVENT_SINGLE_CAFF_TEMPLATES_PATH . 'admin-event-single-settings.template.php', $EE->CFG->template_settings->EED_Event_Single); }
protected function __construct($timezone = NULL) { $this->singular_item = __('Term Relationship', 'event_espresso'); $this->plural_item = __('Term Relationships', 'event_espresso'); $this->_tables = array('Term_Relationship' => new EE_Primary_Table('term_relationships')); $models_this_can_attach_to = array_keys(EE_Registry::instance()->cpt_models()); $this->_fields = array('Term_Relationship' => array('object_id' => new EE_Foreign_Key_Int_Field('object_id', __('Object(Post) ID', 'event_espresso'), false, 0, $models_this_can_attach_to), 'term_taxonomy_id' => new EE_Foreign_Key_Int_Field('term_taxonomy_id', __('Term (in context of a taxonomy) ID', 'event_espresso'), false, 0, 'Term_Taxonomy'), 'term_order' => new EE_Integer_Field('term_order', __('Term Order', 'event_espresso'), false, 0))); $this->_model_relations = array('Term_Taxonomy' => new EE_Belongs_To_Relation()); foreach ($models_this_can_attach_to as $model_name) { $this->_model_relations[$model_name] = new EE_Belongs_To_Relation(); } $this->_indexes = array('PRIMARY' => new EE_Primary_Key_Index(array('object_id', 'term_taxonomy_id'))); $path_to_event_model = 'Event.'; $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public($path_to_event_model); $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event_model); $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event_model); $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event_model, EEM_Base::caps_edit); $path_to_tax_model = 'Term_Taxonomy.'; //add cap restrictions for editing term relations to the "ee_assign_*" //and for deleting term relations too $cap_contexts_affected = array(EEM_Base::caps_edit, EEM_Base::caps_delete); foreach ($cap_contexts_affected as $cap_context_affected) { $this->_cap_restrictions[$cap_context_affected]['ee_assign_event_category'] = new EE_Default_Where_Conditions(array($path_to_tax_model . 'taxonomy*ee_assign_event_category' => array('!=', 'espresso_event_categories'))); $this->_cap_restrictions[$cap_context_affected]['ee_assign_venue_category'] = new EE_Default_Where_Conditions(array($path_to_tax_model . 'taxonomy*ee_assign_venue_category' => array('!=', 'espresso_venue_categories'))); $this->_cap_restrictions[$cap_context_affected]['ee_assign_event_type'] = new EE_Default_Where_Conditions(array($path_to_tax_model . 'taxonomy*ee_assign_event_type' => array('!=', 'espresso_event_type'))); } parent::__construct($timezone); }
/** * run * * initial shortcode module setup called during "wp_loaded" hook * this method is primarily used for loading resources that will be required by the shortcode when it is actually processed * * @access public * @param WP $WP * @return void * @throws \Exception * @throws \EE_Error */ public function run(WP $WP) { $this->_current_txn = null; if (EE_Registry::instance()->REQ->is_set('e_reg_url_link')) { /** @var EEM_Transaction $EEM_Transaction */ $EEM_Transaction = EE_Registry::instance()->load_model('Transaction'); $this->_current_txn = $EEM_Transaction->get_transaction_from_reg_url_link(); } if ($this->_current_txn instanceof EE_Transaction) { $payment_method = null; $payment_method_slug = EE_Registry::instance()->REQ->get('ee_payment_method', null); if ($payment_method_slug) { $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($payment_method_slug); } if ($payment_method instanceof EE_Payment_Method && $payment_method->is_off_site()) { $gateway = $payment_method->type_obj()->get_gateway(); if ($gateway instanceof EE_Offsite_Gateway && $gateway->handle_IPN_in_this_request(\EE_Registry::instance()->REQ->params(), true)) { /** @type EE_Payment_Processor $payment_processor */ $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); $payment_processor->process_ipn($_REQUEST, $this->_current_txn, $payment_method); } } //allow gateways to add a filter to stop rendering the page if (apply_filters('FHEE__EES_Espresso_Txn_Page__run__exit', FALSE)) { exit; } } }
/** * 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)); } }
public function column_display_text(EE_Question $item) { $system_question = $item->is_system_question(); $actions = array(); if (!defined('REG_ADMIN_URL')) { define('REG_ADMIN_URL', EVENTS_ADMIN_URL); } $edit_query_args = array('action' => 'edit_question', 'QST_ID' => $item->ID()); $trash_query_args = array('action' => 'trash_question', 'QST_ID' => $item->ID()); $restore_query_args = array('action' => 'restore_question', 'QST_ID' => $item->ID()); $delete_query_args = array('action' => 'delete_questions', 'QST_ID' => $item->ID()); $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_FORMS_ADMIN_URL); $trash_link = EE_Admin_Page::add_query_args_and_nonce($trash_query_args, EE_FORMS_ADMIN_URL); $restore_link = EE_Admin_Page::add_query_args_and_nonce($restore_query_args, EE_FORMS_ADMIN_URL); $delete_link = EE_Admin_Page::add_query_args_and_nonce($delete_query_args, EE_FORMS_ADMIN_URL); if (EE_Registry::instance()->CAP->current_user_can('ee_edit_question', 'espresso_registration_form_edit_question', $item->ID())) { $actions = array('edit' => '<a href="' . $edit_link . '" title="' . __('Edit Question', 'event_espresso') . '">' . __('Edit', 'event_espresso') . '</a>'); } if (!$system_question && $this->_view != 'trash' && EE_Registry::instance()->CAP->current_user_can('ee_delete_question', 'espresso_registration_form_trash_question', $item->ID())) { $actions['delete'] = '<a href="' . $trash_link . '" title="' . __('Trash Question', 'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>'; } if ($this->_view == 'trash') { if (EE_Registry::instance()->CAP->current_user_can('ee_delete_question', 'espresso_registration_form_restore_question', $item->ID())) { $actions['restore'] = '<a href="' . $restore_link . '" title="' . __('Restore Question', 'event_espresso') . '">' . __('Restore', 'event_espresso') . '</a>'; } if ($item->count_related('Answer') === 0 && EE_Registry::instance()->CAP->current_user_can('ee_delete_question', 'espresso_registration_form_delete_questions', $item->ID())) { $actions['delete_permanently'] = '<a href="' . $delete_link . '" title="' . __('Delete Question Permanently', 'event_espresso') . '">' . __('Delete Permanently', 'event_espresso') . '</a>'; } } $content = EE_Registry::instance()->CAP->current_user_can('ee_edit_question', 'espresso_registration_form_edit_question', $item->ID()) ? '<strong><a class="row-title" href="' . $edit_link . '">' . $item->display_text() . '</a></strong>' : $item->display_text(); $content .= $this->row_actions($actions); return $content; }
public function test_primary_registration() { /** @type EE_Transaction $t */ $t = $this->new_model_obj_with_dependencies('Transaction', NULL, FALSE); $this->assertEquals(0, $t->ID()); /** @type EE_Registration $r */ $r = $this->new_model_obj_with_dependencies('Registration', array('REG_count' => 1), FALSE); $this->assertEquals(0, $r->ID()); $t->_add_relation_to($r, 'Registration'); $this->assertEquals($r, $t->primary_registration()); $r->save(); $this->assertNotEquals(0, $r->ID()); $in_map = EE_Registry::instance()->load_model('Registration')->get_from_entity_map($r->ID()); $this->assertEquals($r, $in_map); $this->assertEquals($r, $t->primary_registration()); $this->assertEquals(1, $r->count()); $r_in_db = EE_Registry::instance()->load_model('Registration')->get_one_by_ID($r->ID()); $this->assertEquals($r, $r_in_db); $t->save(); $this->assertEquals($r, $t->primary_registration()); //why does the above fail? because we forgot to set the registration's TXN_ID! //so it makes sense, but it sure would have been considerate of the transaction if, //when it was saved, it would have set the ID on all foreign keys pointing to it //on things it had cached on itself }
public function test_migrate_old_billing_infos() { $postmeta_name = 'billing_info_Paypal_Pro'; $billing_info = unserialize('a:13:{s:34:"_reg-page-billing-fname-Paypal_Pro";s:3:"few";s:34:"_reg-page-billing-lname-Paypal_Pro";s:3:"few";s:34:"_reg-page-billing-email-Paypal_Pro";s:9:"*****@*****.**";s:34:"_reg-page-billing-phone-Paypal_Pro";s:1:"f";s:36:"_reg-page-billing-address-Paypal_Pro";s:1:"f";s:33:"_reg-page-billing-city-Paypal_Pro";s:1:"f";s:34:"_reg-page-billing-state-Paypal_Pro";i:6;s:36:"_reg-page-billing-country-Paypal_Pro";s:2:"CA";s:32:"_reg-page-billing-zip-Paypal_Pro";s:1:"c";s:38:"_reg-page-billing-card-nmbr-Paypal_Pro";s:16:"XXXXXXXXXXXX7383";s:38:"_reg-page-billing-card-type-Paypal_Pro";s:10:"MasterCard";s:47:"_reg-page-billing-card-exp-date-mnth-Paypal_Pro";s:2:"01";s:47:"_reg-page-billing-card-exp-date-year-Paypal_Pro";s:2:"17";}'); $att1 = $this->new_model_obj_with_dependencies('Attendee'); $att1->update_post_meta($postmeta_name, $billing_info); $att2 = $this->new_model_obj_with_dependencies('Attendee'); $att2->update_post_meta($postmeta_name, $billing_info); //load teh dms, which should autoload the stage we want to test $script = EE_Registry::instance()->load_dms('EE_DMS_Core_4_6_0'); $stage = new EE_DMS_4_6_0_billing_info(); $stage->_construct_finalize($script); $this->assertEquals(2, $stage->count_records_to_migrate()); // var_dump($stage); $stage->migration_step(1); $this->assertEquals(1, $stage->count_records_migrated()); //get that updated postmeta $new_billing_info = $att1->get_post_meta($postmeta_name, TRUE); $this->assertNotEquals($billing_info, $new_billing_info); $this->assertArrayHasKey('first_name', $new_billing_info); //verify we only migrated what we said we would- the first item only $this->assertEquals($billing_info, $att2->get_post_meta($postmeta_name, TRUE)); //now migrate the next one $stage->migration_step(1); }
/** * Writes $data to the csv file open in $filehandle. uses the array indices of $data for column headers * * @param string $filepath * @param array $data 2D array, first numerically-indexed, * and next-level-down preferably indexed by string * @param boolean $write_column_headers whether or not we should add the keys in the bottom-most array * as a row for headers in the CSV. * Eg, if $data looked like: * array( * 0=>array('EVT_ID'=>1,'EVT_name'=>'monkey'...), * 1=>array(...,...) * ) * * @return boolean if we successfully wrote to the CSV or not. If there's no $data, * we consider that a success (because we wrote everything there was...nothing) * @throws EE_Error */ public static function write_data_array_to_csv($filepath, $data, $write_column_headers = true) { EE_Registry::instance()->load_helper('Array'); $new_file_contents = ''; //determine if $data is actually a 2d array if ($data && is_array($data) && is_array(EEH_Array::get_one_item_from_array($data))) { //make sure top level is numerically indexed, if (EEH_Array::is_associative_array($data)) { throw new EE_Error(sprintf(__("top-level array must be numerically indexed. Does these look like numbers to you? %s", "event_espresso"), implode(",", array_keys($data)))); } $item_in_top_level_array = EEH_Array::get_one_item_from_array($data); //now, is the last item in the top-level array of $data an associative or numeric array? if ($write_column_headers && EEH_Array::is_associative_array($item_in_top_level_array)) { //its associative, so we want to output its keys as column headers $keys = array_keys($item_in_top_level_array); $new_file_contents .= EEH_Export::get_csv_row($keys); } //start writing data foreach ($data as $data_row) { $new_file_contents .= EEH_Export::get_csv_row($data_row); } return EEH_File::write_to_file($filepath, EEH_File::get_file_contents($filepath) . $new_file_contents); } else { //no data TO write... so we can assume that's a success return true; } }
protected function __construct($timezone = NULL) { $this->singular_item = __('Term Taxonomy', 'event_espresso'); $this->plural_item = __('Term Taxonomy', 'event_espresso'); $this->_tables = array('Term_Taxonomy' => new EE_Primary_Table('term_taxonomy', 'term_taxonomy_id')); $this->_fields = array('Term_Taxonomy' => array('term_taxonomy_id' => new EE_Primary_Key_Int_Field('term_taxonomy_id', __('Term-Taxonomy ID', 'event_espresso')), 'term_id' => new EE_Foreign_Key_Int_Field('term_id', __("Term Id", "event_espresso"), false, 0, 'Term'), 'taxonomy' => new EE_Plain_Text_Field('taxonomy', __('Taxonomy Name', 'event_espresso'), false, 'category'), 'description' => new EE_Post_Content_Field('description', __("Description of Term", "event_espresso"), false, ''), 'parent' => new EE_Integer_Field('parent', __("Parent Term ID", "event_espresso"), false, 0), 'term_count' => new EE_Integer_Field('count', __("Count of Objects attached", 'event_espresso'), false, 0))); $this->_model_relations = array('Term_Relationship' => new EE_Has_Many_Relation(), 'Term' => new EE_Belongs_To_Relation()); $cpt_models = array_keys(EE_Registry::instance()->cpt_models()); foreach ($cpt_models as $model_name) { $this->_model_relations[$model_name] = new EE_HABTM_Relation('Term_Relationship'); } $this->_indexes = array('term_id_taxonomy' => new EE_Unique_Index(array('term_id', 'taxonomy'))); $path_to_tax_model = ''; $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Taxonomy_Protected($path_to_tax_model); $this->_cap_restriction_generators[EEM_Base::caps_edit] = false; $this->_cap_restriction_generators[EEM_Base::caps_delete] = false; //add cap restrictions for editing relating to the "ee_edit_*" $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_category'] = new EE_Default_Where_Conditions(array($path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'))); $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(array($path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'))); $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_type'] = new EE_Default_Where_Conditions(array($path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'))); //add cap restrictions for deleting relating to the "ee_deleting_*" $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_category'] = new EE_Default_Where_Conditions(array($path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'))); $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(array($path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'))); $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_type'] = new EE_Default_Where_Conditions(array($path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'))); parent::__construct($timezone); }
/** * parse_post_content_on_save * * any time a post is saved, we need to check for any EE shortcodes that may be embedded in the content, * and then track what posts those shortcodes are on, so that we can initialize shortcodes well before the_content() runs. * this allows us to do things like enqueue scripts for shortcodes ONLY on the pages the shortcodes are actually used on * * @access public * @param int $post_ID * @param \WP_Post $post * @return void */ public static function parse_post_content_on_save($post_ID, $post) { // if the post is trashed, then let's remove our post shortcode tracking if ($post instanceof \WP_Post && $post->post_status === 'trash') { PostShortcodeTracking::unset_post_shortcodes_on_delete($post_ID); return; } // default post types $post_types = array('post' => 0, 'page' => 1); // add CPTs $CPTs = \EE_Register_CPTs::get_CPTs(); $post_types = array_merge($post_types, $CPTs); // for default or CPT posts... if (isset($post_types[$post->post_type])) { // post on frontpage ? $page_for_posts = \EE_Config::get_page_for_posts(); if ($post->post_name === $page_for_posts) { PostShortcodeTracking::set_post_shortcodes_for_posts_page($page_for_posts); return; } // array of shortcodes indexed by post name \EE_Registry::CFG()->core->post_shortcodes = isset(\EE_Registry::CFG()->core->post_shortcodes) ? \EE_Registry::CFG()->core->post_shortcodes : array(); // whether to proceed with update $update_post_shortcodes = false; // empty both arrays \EE_Registry::CFG()->core->post_shortcodes[$post->post_name] = array(); // check that posts page is already being tracked if (!isset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts])) { // if not, then ensure that it is properly added \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts] = array(); } // loop thru shortcodes foreach (\EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir) { // convert to UPPERCASE to get actual shortcode $EES_Shortcode = strtoupper($EES_Shortcode); // is the shortcode in the post_content ? if (strpos($post->post_content, $EES_Shortcode) !== false) { // map shortcode to post names and post IDs \EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode] = $post_ID; // and add this shortcode to the tracking for the blog page PostShortcodeTracking::set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID); $update_post_shortcodes = true; } else { // shortcode is not present in post content, so check if we were tracking it previously // stop tracking if shortcode is not used in this specific post if (isset(\EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode])) { unset(\EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode]); $update_post_shortcodes = true; } // make sure that something is set for the shortcode posts (even though we may remove this) $shortcode_posts = isset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode]) ? \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] : array(); // and stop tracking for this shortcode on the blog page if it is not used $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post($post_ID, $EES_Shortcode, $shortcode_posts, $page_for_posts, $update_post_shortcodes) ? true : $update_post_shortcodes; } } if ($update_post_shortcodes) { PostShortcodeTracking::update_post_shortcodes($page_for_posts); } } }
public function __construct($template_file, $args = array(), $options_array = array()) { EE_Registry::instance()->load_helper('Template'); $html = EEH_Template::locate_template($template_file, $args); // echo " filepath:$template_file html $html"; parent::__construct($html, $options_array); }
protected function _add_view_counts() { $this->_views['all']['count'] = $this->_all_data_count; if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_tickets', 'trash_ticket')) { $this->_views['trashed']['count'] = $this->_trashed_count; } }
/** * Validate an email address. * Provide email address (raw input) * * @param $email * @return bool of whether the email is valid or not * @throws \EE_Validation_Error */ private function _validate_email($email) { $validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level) ? EE_Registry::instance()->CFG->registration->email_validation_level : 'wp_default'; if (!preg_match('/^.+\\@\\S+$/', $email)) { // \.\S+ // email not in correct {string}@{string} format return false; } else { $atIndex = strrpos($email, "@"); $domain = substr($email, $atIndex + 1); $local = substr($email, 0, $atIndex); $localLen = strlen($local); $domainLen = strlen($domain); if ($localLen < 1 || $localLen > 64) { // local part length exceeded return false; } else { if ($domainLen < 1 || $domainLen > 255) { // domain part length exceeded return false; } else { if ($local[0] === '.' || $local[$localLen - 1] === '.') { // local part starts or ends with '.' return false; } else { if (preg_match('/\\.\\./', $local)) { // local part has two consecutive dots return false; } else { if (preg_match('/\\.\\./', $domain)) { // domain part has two consecutive dots return false; } else { if ($validation_level === 'wp_default') { return is_email($email); } else { if (($validation_level === 'i18n' || $validation_level === 'i18n_dns') && !preg_match('/^(?!\\.)((?!.*\\.{2})[a-zA-Z0-9\\x{0080}-\\x{00FF}\\x{0100}-\\x{017F}\\x{0180}-\\x{024F}\\x{0250}-\\x{02AF}\\x{0300}-\\x{036F}\\x{0370}-\\x{03FF}\\x{0400}-\\x{04FF}\\x{0500}-\\x{052F}\\x{0530}-\\x{058F}\\x{0590}-\\x{05FF}\\x{0600}-\\x{06FF}\\x{0700}-\\x{074F}\\x{0750}-\\x{077F}\\x{0780}-\\x{07BF}\\x{07C0}-\\x{07FF}\\x{0900}-\\x{097F}\\x{0980}-\\x{09FF}\\x{0A00}-\\x{0A7F}\\x{0A80}-\\x{0AFF}\\x{0B00}-\\x{0B7F}\\x{0B80}-\\x{0BFF}\\x{0C00}-\\x{0C7F}\\x{0C80}-\\x{0CFF}\\x{0D00}-\\x{0D7F}\\x{0D80}-\\x{0DFF}\\x{0E00}-\\x{0E7F}\\x{0E80}-\\x{0EFF}\\x{0F00}-\\x{0FFF}\\x{1000}-\\x{109F}\\x{10A0}-\\x{10FF}\\x{1100}-\\x{11FF}\\x{1200}-\\x{137F}\\x{1380}-\\x{139F}\\x{13A0}-\\x{13FF}\\x{1400}-\\x{167F}\\x{1680}-\\x{169F}\\x{16A0}-\\x{16FF}\\x{1700}-\\x{171F}\\x{1720}-\\x{173F}\\x{1740}-\\x{175F}\\x{1760}-\\x{177F}\\x{1780}-\\x{17FF}\\x{1800}-\\x{18AF}\\x{1900}-\\x{194F}\\x{1950}-\\x{197F}\\x{1980}-\\x{19DF}\\x{19E0}-\\x{19FF}\\x{1A00}-\\x{1A1F}\\x{1B00}-\\x{1B7F}\\x{1D00}-\\x{1D7F}\\x{1D80}-\\x{1DBF}\\x{1DC0}-\\x{1DFF}\\x{1E00}-\\x{1EFF}\\x{1F00}-\\x{1FFF}\\x{20D0}-\\x{20FF}\\x{2100}-\\x{214F}\\x{2C00}-\\x{2C5F}\\x{2C60}-\\x{2C7F}\\x{2C80}-\\x{2CFF}\\x{2D00}-\\x{2D2F}\\x{2D30}-\\x{2D7F}\\x{2D80}-\\x{2DDF}\\x{2F00}-\\x{2FDF}\\x{2FF0}-\\x{2FFF}\\x{3040}-\\x{309F}\\x{30A0}-\\x{30FF}\\x{3100}-\\x{312F}\\x{3130}-\\x{318F}\\x{3190}-\\x{319F}\\x{31C0}-\\x{31EF}\\x{31F0}-\\x{31FF}\\x{3200}-\\x{32FF}\\x{3300}-\\x{33FF}\\x{3400}-\\x{4DBF}\\x{4DC0}-\\x{4DFF}\\x{4E00}-\\x{9FFF}\\x{A000}-\\x{A48F}\\x{A490}-\\x{A4CF}\\x{A700}-\\x{A71F}\\x{A800}-\\x{A82F}\\x{A840}-\\x{A87F}\\x{AC00}-\\x{D7AF}\\x{F900}-\\x{FAFF}\\.!#$%&\'*+-\\/=?^_`{|}~\\-\\d]+)@(?!\\.)([a-zA-Z0-9\\x{0080}-\\x{00FF}\\x{0100}-\\x{017F}\\x{0180}-\\x{024F}\\x{0250}-\\x{02AF}\\x{0300}-\\x{036F}\\x{0370}-\\x{03FF}\\x{0400}-\\x{04FF}\\x{0500}-\\x{052F}\\x{0530}-\\x{058F}\\x{0590}-\\x{05FF}\\x{0600}-\\x{06FF}\\x{0700}-\\x{074F}\\x{0750}-\\x{077F}\\x{0780}-\\x{07BF}\\x{07C0}-\\x{07FF}\\x{0900}-\\x{097F}\\x{0980}-\\x{09FF}\\x{0A00}-\\x{0A7F}\\x{0A80}-\\x{0AFF}\\x{0B00}-\\x{0B7F}\\x{0B80}-\\x{0BFF}\\x{0C00}-\\x{0C7F}\\x{0C80}-\\x{0CFF}\\x{0D00}-\\x{0D7F}\\x{0D80}-\\x{0DFF}\\x{0E00}-\\x{0E7F}\\x{0E80}-\\x{0EFF}\\x{0F00}-\\x{0FFF}\\x{1000}-\\x{109F}\\x{10A0}-\\x{10FF}\\x{1100}-\\x{11FF}\\x{1200}-\\x{137F}\\x{1380}-\\x{139F}\\x{13A0}-\\x{13FF}\\x{1400}-\\x{167F}\\x{1680}-\\x{169F}\\x{16A0}-\\x{16FF}\\x{1700}-\\x{171F}\\x{1720}-\\x{173F}\\x{1740}-\\x{175F}\\x{1760}-\\x{177F}\\x{1780}-\\x{17FF}\\x{1800}-\\x{18AF}\\x{1900}-\\x{194F}\\x{1950}-\\x{197F}\\x{1980}-\\x{19DF}\\x{19E0}-\\x{19FF}\\x{1A00}-\\x{1A1F}\\x{1B00}-\\x{1B7F}\\x{1D00}-\\x{1D7F}\\x{1D80}-\\x{1DBF}\\x{1DC0}-\\x{1DFF}\\x{1E00}-\\x{1EFF}\\x{1F00}-\\x{1FFF}\\x{20D0}-\\x{20FF}\\x{2100}-\\x{214F}\\x{2C00}-\\x{2C5F}\\x{2C60}-\\x{2C7F}\\x{2C80}-\\x{2CFF}\\x{2D00}-\\x{2D2F}\\x{2D30}-\\x{2D7F}\\x{2D80}-\\x{2DDF}\\x{2F00}-\\x{2FDF}\\x{2FF0}-\\x{2FFF}\\x{3040}-\\x{309F}\\x{30A0}-\\x{30FF}\\x{3100}-\\x{312F}\\x{3130}-\\x{318F}\\x{3190}-\\x{319F}\\x{31C0}-\\x{31EF}\\x{31F0}-\\x{31FF}\\x{3200}-\\x{32FF}\\x{3300}-\\x{33FF}\\x{3400}-\\x{4DBF}\\x{4DC0}-\\x{4DFF}\\x{4E00}-\\x{9FFF}\\x{A000}-\\x{A48F}\\x{A490}-\\x{A4CF}\\x{A700}-\\x{A71F}\\x{A800}-\\x{A82F}\\x{A840}-\\x{A87F}\\x{AC00}-\\x{D7AF}\\x{F900}-\\x{FAFF}\\-\\.\\d]+)((\\.([a-zA-Z\\x{0080}-\\x{00FF}\\x{0100}-\\x{017F}\\x{0180}-\\x{024F}\\x{0250}-\\x{02AF}\\x{0300}-\\x{036F}\\x{0370}-\\x{03FF}\\x{0400}-\\x{04FF}\\x{0500}-\\x{052F}\\x{0530}-\\x{058F}\\x{0590}-\\x{05FF}\\x{0600}-\\x{06FF}\\x{0700}-\\x{074F}\\x{0750}-\\x{077F}\\x{0780}-\\x{07BF}\\x{07C0}-\\x{07FF}\\x{0900}-\\x{097F}\\x{0980}-\\x{09FF}\\x{0A00}-\\x{0A7F}\\x{0A80}-\\x{0AFF}\\x{0B00}-\\x{0B7F}\\x{0B80}-\\x{0BFF}\\x{0C00}-\\x{0C7F}\\x{0C80}-\\x{0CFF}\\x{0D00}-\\x{0D7F}\\x{0D80}-\\x{0DFF}\\x{0E00}-\\x{0E7F}\\x{0E80}-\\x{0EFF}\\x{0F00}-\\x{0FFF}\\x{1000}-\\x{109F}\\x{10A0}-\\x{10FF}\\x{1100}-\\x{11FF}\\x{1200}-\\x{137F}\\x{1380}-\\x{139F}\\x{13A0}-\\x{13FF}\\x{1400}-\\x{167F}\\x{1680}-\\x{169F}\\x{16A0}-\\x{16FF}\\x{1700}-\\x{171F}\\x{1720}-\\x{173F}\\x{1740}-\\x{175F}\\x{1760}-\\x{177F}\\x{1780}-\\x{17FF}\\x{1800}-\\x{18AF}\\x{1900}-\\x{194F}\\x{1950}-\\x{197F}\\x{1980}-\\x{19DF}\\x{19E0}-\\x{19FF}\\x{1A00}-\\x{1A1F}\\x{1B00}-\\x{1B7F}\\x{1D00}-\\x{1D7F}\\x{1D80}-\\x{1DBF}\\x{1DC0}-\\x{1DFF}\\x{1E00}-\\x{1EFF}\\x{1F00}-\\x{1FFF}\\x{20D0}-\\x{20FF}\\x{2100}-\\x{214F}\\x{2C00}-\\x{2C5F}\\x{2C60}-\\x{2C7F}\\x{2C80}-\\x{2CFF}\\x{2D00}-\\x{2D2F}\\x{2D30}-\\x{2D7F}\\x{2D80}-\\x{2DDF}\\x{2F00}-\\x{2FDF}\\x{2FF0}-\\x{2FFF}\\x{3040}-\\x{309F}\\x{30A0}-\\x{30FF}\\x{3100}-\\x{312F}\\x{3130}-\\x{318F}\\x{3190}-\\x{319F}\\x{31C0}-\\x{31EF}\\x{31F0}-\\x{31FF}\\x{3200}-\\x{32FF}\\x{3300}-\\x{33FF}\\x{3400}-\\x{4DBF}\\x{4DC0}-\\x{4DFF}\\x{4E00}-\\x{9FFF}\\x{A000}-\\x{A48F}\\x{A490}-\\x{A4CF}\\x{A700}-\\x{A71F}\\x{A800}-\\x{A82F}\\x{A840}-\\x{A87F}\\x{AC00}-\\x{D7AF}\\x{F900}-\\x{FAFF}]){2,63})+)$/u', $email)) { return false; } } } } } } } if ($validation_level === 'i18n_dns') { if (!checkdnsrr($domain, "MX")) { // domain not found in MX records throw new EE_Validation_Error(__('Although the email address provided is formatted correctly, a valid "MX record" could not be located for that address and domain. Please enter a valid email address.', 'event_espresso')); } else { if (!checkdnsrr($domain, "A")) { // domain not found in A records throw new EE_Validation_Error(__('Although the email address provided is formatted correctly, a valid "A record" could not be located for that address and domain. Please enter a valid email address.', 'event_espresso')); } } } } // you have successfully run the gauntlet young Padawan return true; }
/** * Gets the form for all the settings related to this payment method type * @return EE_Payment_Method_Form */ public function generate_new_settings_form() { EE_Registry::instance()->load_helper('Template'); $credit_card_types = $this->credit_card_types(); $form = new EE_Payment_Method_Form(array('extra_meta_inputs' => array('merchant_id' => new EE_Text_Input(array('html_label_text' => sprintf(__("Connection Merchant ID %s", "event_espresso"), $this->get_help_tab_link()))), 'connection_username' => new EE_Text_Input(array('html_label_text' => sprintf(__("Connection Username %s", "event_espresso"), $this->get_help_tab_link()))), 'connection_password' => new EE_Password_Input(array('html_label_text' => sprintf(__("Connection Password %s", "event_espresso"), $this->get_help_tab_link()))), 'terminal_id' => new EE_Text_Input(array('html_label_text' => sprintf(__("Terminal ID %s", "event_espresso"), $this->get_help_tab_link()), 'default' => '001')), 'bin' => new EE_Text_Input(array('html_label_text' => sprintf(__("BIN %s", "event_espresso"), $this->get_help_tab_link()), 'default' => '000002')), 'credit_card_types' => new EE_Checkbox_Multi_Input($credit_card_types, array('html_label_text' => sprintf(__("Required Payment Form Fields %s", 'event_espresso'), $this->get_help_tab_link()), 'default' => array_keys($credit_card_types)))))); return $form; }
protected function _setup_data() { //basically ALL we're going to get from this is the transaction object and use it to build the majority of our info. $session = $this->_data->get_session_data(); $this->txn = $session['transaction']; if (empty($this->txn) || !$this->txn instanceof EE_Transaction) { throw new EE_Error(__('Incoming data for the EE_Session data handler must have a valid EE_Transaction object in order to setup the data')); } $this->reg_info = array(); $this->incoming_data = $session; $this->taxes = $this->txn->tax_total(); $this->grand_total_price_object = ''; //other data from the session (if possible) $this->user_id = isset($session['user_id']) ? $session['user_id'] : ''; $this->ip_address = isset($session['ip_address']) ? $session['ip_address'] : ''; $this->user_agent = isset($session['user_agent']) ? $session['user_agent'] : ''; $this->init_access = $this->last_access = ''; $this->payment = $this->txn->get_first_related('Payment'); $this->payment = empty($this->payment) ? EE_Payment::new_instance(array('STS_ID' => EEM_Payment::status_id_pending, 'PAY_timestamp' => (int) current_time('timestamp'), 'PAY_gateway' => $this->txn->selected_gateway(), 'PAY_gateway_response' => $this->txn->gateway_response_on_transaction())) : $this->payment; //if there is no payments associated with the transaction then we just create a default payment object for potential parsing. $this->billing = $this->payment->details(); EE_Registry::instance()->load_helper('Template'); $this->billing['total_due'] = isset($this->billing['total']) ? EEH_Template::format_currency($this->billing['total']) : ''; //let's get all the registrations associated with this txn $this->reg_objs = $this->txn->registrations(); $this->_assemble_data(); }
protected function _parser($shortcode) { EE_Registry::instance()->load_helper('Template'); if (!$this->_data instanceof EE_Ticket) { return ''; } //get out cause we can only parse with the ticket object. switch ($shortcode) { case '[TICKET_ID]': return $this->_data->ID(); break; case '[TICKET_NAME]': return $this->_data->get('TKT_name'); break; case '[TICKET_DESCRIPTION]': return $this->_data->get('TKT_description'); break; case '[TICKET_PRICE]': return EEH_Template::format_currency($this->_data->get('TKT_price')); break; case '[TKT_QTY_PURCHASED]': return $this->_extra_data['data']->tickets[$this->_data->ID()]['count']; break; } }
/** * * @throws EE_Error * @return string of html to display the field */ public function display() { if (!$this->_input instanceof EE_Form_Input_With_Options_Base) { throw new EE_Error(sprintf(__('Cannot use Select Multiple Display Strategy with an input that doesn\'t have options', "event_espresso"))); } $html = EEH_HTML::nl(0, 'select'); $html .= '<select multiple'; $html .= ' id="' . $this->_input->html_id() . '"'; $html .= ' name="' . $this->_input->html_name() . '[]"'; $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class(); $html .= ' class="' . $class . '"'; // add html5 required $html .= $this->_input->required() ? ' required' : ''; $html .= ' style="' . $this->_input->html_style() . '"'; $html .= '>'; EE_Registry::instance()->load_helper('Array'); EEH_HTML::indent(1, 'select'); if (EEH_Array::is_multi_dimensional_array($this->_input->options())) { throw new EE_Error(sprintf(__("Select multiple display strategy does not allow for nested arrays of options.", "event_espresso"))); } else { $html .= $this->_display_options($this->_input->options()); } $html .= EEH_HTML::nl(-1, 'select') . "</select>"; return $html; }
/** * This tests the generate_default_message_templates method with using the * FHEE__EE_messenger__get_default_message_types__default_types filter to add a * bogus message_type string. No errors should be triggered, and the invalid default mt * should NOT be added to the active array for the messenger. * * @since 4.6 * @group 7595 */ public function test_filtered_default_message_types_on_activation() { EE_Registry::instance()->load_helper('MSG_Template'); EE_Registry::instance()->load_helper('Activation'); //let's clear out all active messengers to get an accurate test of initial generation of message templates. global $wpdb; $mtpg_table = $wpdb->prefix . 'esp_message_template_group'; $mtp_table = $wpdb->prefix . 'esp_message_template'; $evt_mtp_table = $wpdb->prefix . 'esp_event_message_template'; $query = "DELETE FROM {$mtpg_table} WHERE 'GRP_ID' > 0"; $wpdb->query($query); $query = "DELETE FROM {$mtp_table} WHERE 'MTP_ID' > 0"; $wpdb->query($query); $query = "DELETE FROM {$evt_mtp_table} WHERE 'EMT_ID' > 0"; $wpdb->query($query); EEH_MSG_Template::update_active_messengers_in_db(array()); //set a filter for the invalid message type add_filter('FHEE__EE_messenger__get_default_message_types__default_types', function ($default_types, $messenger) { $default_types[] = 'bogus_message_type'; return $default_types; }, 10, 2); //activate messages... if there's any problems then errors will trigger a fail. EEH_Activation::generate_default_message_templates(); //all went well so let's make sure the activated system does NOT have our invalid message type string. $active_messengers = EEH_MSG_Template::get_active_messengers_in_db(); foreach ($active_messengers as $messenger => $settings) { $this->assertFalse(isset($settings['settings'][$messenger . '-message_types']['bogus_message_type']), sprintf('The %s messenger should not have "bogus_message_type" active on it but it does.', $messenger)); } }
function column_ATT_fname($item) { //Build row actions $actions = array(); // edit attendee link if (EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts', 'espresso_registrations_edit_attendee')) { $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit_attendee', 'post' => $item->ID()), REG_ADMIN_URL); $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('Edit Contact', 'event_espresso') . '">' . __('Edit', 'event_espresso') . '</a>'; } if ($this->_view == 'in_use') { // trash attendee link if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', 'espresso_registrations_trash_attendees')) { $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'trash_attendees', 'ATT_ID' => $item->ID()), REG_ADMIN_URL); $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' . esc_attr__('Move Contact to Trash', 'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>'; } } else { if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', 'espresso_registrations_restore_attendees')) { // restore attendee link $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'restore_attendees', 'ATT_ID' => $item->ID()), REG_ADMIN_URL); $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' . esc_attr__('Restore Contact', 'event_espresso') . '">' . __('Restore', 'event_espresso') . '</a>'; } } $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit_attendee', 'post' => $item->ID()), REG_ADMIN_URL); $name_link = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts', 'espresso_registrations_edit_attendee') ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('Edit Contact', 'event_espresso') . '">' . $item->fname() . '</a>' : $item->fname(); //Return the name contents return sprintf('%1$s %2$s', $name_link, $this->row_actions($actions)); }
/** * * @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 Select Display Strategy with an input that doesn\'t have options', 'event_espresso'))); } EE_Registry::instance()->load_helper('Array'); $html = EEH_HTML::nl(0, 'select'); $html .= '<select'; $html .= ' id="' . $this->_input->html_id() . '"'; $html .= ' name="' . $this->_input->html_name() . '"'; $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class(); $html .= ' class="' . $class . '"'; // add html5 required $html .= $this->_input->required() ? ' required' : ''; $html .= ' style="' . $this->_input->html_style() . '"'; $html .= '>'; // EEH_HTML::indent( 1, 'select' ); if (EEH_Array::is_multi_dimensional_array($this->_input->options())) { EEH_HTML::indent(1, 'optgroup'); foreach ($this->_input->options() as $opt_group_label => $opt_group) { $html .= EEH_HTML::nl(0, 'optgroup') . '<optgroup label="' . esc_attr($opt_group_label) . '">'; EEH_HTML::indent(1, 'option'); $html .= $this->_display_options($opt_group); $html .= EEH_HTML::indent(-1, 'option'); $html .= EEH_HTML::nl(0, 'optgroup') . '</optgroup>'; } EEH_HTML::indent(-1, 'optgroup'); } else { $html .= $this->_display_options($this->_input->options()); } $html .= EEH_HTML::nl(0, 'select') . '</select>'; // $html.= EEH_HTML::nl( -1, 'select' ) . '</select>'; return $html; }
protected function _default_settings() { $org_config = EE_Registry::instance()->CFG->organization; $default_address = trim($org_config->address_1); $default_address .= empty($org_config->address_2) ? '' : '<br />' . trim($org_config->address_2); $default_address .= '<br />' . trim($org_config->city); $state_obj = EE_Registry::instance()->load_model('State')->get_one_by_ID($org_config->STA_ID); if ($state_obj) { $default_address .= ',' . $state_obj->name(); } $country_obj = EE_Registry::instance()->load_model('Country')->get_one_by_ID($org_config->CNT_ISO); if ($country_obj) { $default_address .= '<br />' . $country_obj->name(); } $default_address .= '<br />' . trim($org_config->zip); $this->_payment_settings['active'] = ''; $this->_payment_settings['pdf_title'] = __('Invoice Payments', 'event_espresso'); $this->_payment_settings['pdf_instructions'] = __('Please send this invoice with payment attached to the address above, or use the payment link below. Payment must be received within 48 hours of event date.', 'event_espresso'); $this->_payment_settings['page_instructions'] = __('Please send Invoice to the address below. Payment must be received within 48 hours of event date.', 'event_espresso'); $this->_payment_settings['payable_to'] = trim($org_config->name); $this->_payment_settings['payment_address'] = $default_address; $this->_payment_settings['invoice_logo_url'] = ''; $this->_payment_settings['show'] = true; $this->_payment_settings['invoice_css'] = ''; $this->_payment_settings['type'] = 'off-line'; $this->_payment_settings['display_name'] = __('Invoice', 'event_espresso'); $this->_payment_settings['current_path'] = ''; $this->_payment_settings['button_url'] = $this->_btn_img; }
/** * This tests a soft delete trash and restore of a cpt model item. * Test prompted by https://events.codebasehq.com/projects/event-espresso/tickets/6625 * * @since 4.4.0 * * @return void */ public function test_soft_trash_restore_cpt_from_model_context() { //create attendee model object and dependencies. $attendee = $this->new_model_obj_with_dependencies('Attendee'); //verify have an attendeee object $this->assertInstanceOf('EE_Attendee', $attendee); //use this attendee_id for every model request. $att_id = $attendee->ID(); //reset model EE_Registry::instance()->reset_model('Attendee'); //verify not trashed. $status = $attendee->status(); $this->assertFalse($status == 'trash'); //k now let's trash it EEM_Attendee::instance()->delete_by_ID($att_id); //verify $trash_attendee = EEM_Attendee::instance()->get_one_by_ID($att_id); $this->assertInstanceOf('EE_Attendee', $trash_attendee); $status = $trash_attendee->status(); $this->assertTrue($status == 'trash'); //reset model again EE_Registry::instance()->reset_model('Attendee'); //now let's try to restore. EEM_Attendee::instance()->restore_by_ID($att_id); $restore_attendee = EEM_Attendee::instance()->get_one_by_ID($att_id); $this->assertInstanceOf('EE_Attendee', $restore_attendee); $status = $restore_attendee->status(); $this->assertFalse($status == 'trash'); }
/** * 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); } }
/** * 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(); } }
/** * debug_logging_options * * @param array $template_args * @return void */ public function debug_logging_options($template_args = array()) { $template_args['use_full_logging'] = EE_Registry::instance()->CFG->admin->use_full_logging; $template_args['use_remote_logging'] = isset(EE_Registry::instance()->CFG->admin->use_remote_logging) ? absint(EE_Registry::instance()->CFG->admin->use_remote_logging) : FALSE; $template_args['remote_logging_url'] = isset(EE_Registry::instance()->CFG->admin->remote_logging_url) && !empty(EE_Registry::instance()->CFG->admin->remote_logging_url) ? stripslashes(EE_Registry::instance()->CFG->admin->remote_logging_url) : ''; $template = GEN_SET_CAF_TEMPLATE_PATH . 'debug_log_settings.template.php'; EEH_Template::display_template($template, $template_args); }
/** * config * * @return EE_New_Addon_Config */ public function config() { // config settings are setup up individually for EED_Modules via the EE_Configurable class that all modules inherit from, so // $this->config(); can be used anywhere to retrieve it's config, and: // $this->_update_config( $EE_Config_Base_object ); can be used to supply an updated instance of it's config object // to piggy back off of the config setup for the base EE_New_Addon class, just use the following (note: updates would have to occur from within that class) return EE_Registry::instance()->addons->EE_New_Addon->config(); }
/** * run - initial shortcode module setup called during "wp_loaded" hook * this method is primarily used for loading resources that will be required by the shortcode when it is actually processed * * @access public * @param WP $WP * @return void */ public function run(WP $WP) { if (EE_Registry::instance()->REQ->is_set('e_reg_url_link') && EE_Registry::instance()->REQ->is_set('ee_gateway')) { $this->_current_txn = EE_Registry::instance()->load_model('Transaction')->get_transaction_from_reg_url_link(); EEM_Gateways::instance()->set_selected_gateway(EE_Registry::instance()->REQ->get('ee_gateway')); EEM_Gateways::instance()->handle_ipn_for_transaction($this->_current_txn); } }