/** * just checks the field isn't blank * * @param $normalized_value * @return bool * @throws \EE_Validation_Error */ function validate($normalized_value) { if ($normalized_value) { if (filter_var($normalized_value, FILTER_VALIDATE_URL) === false) { throw new EE_Validation_Error($this->get_validation_error_message(), 'invalid_url'); } else { if (!EEH_URL::remote_file_exists($normalized_value, array('sslverify' => false, 'limit_response_size' => 4095))) { throw new EE_Validation_Error(sprintf(__("That URL seems to be broken. Please enter a valid URL", "event_espresso"))); } } } }
/** * just checks the field isn't blank * * @param $normalized_value * @return bool * @throws \EE_Validation_Error */ function validate($normalized_value) { if ($normalized_value) { if (filter_var($normalized_value, FILTER_VALIDATE_URL) === false) { throw new EE_Validation_Error($this->get_validation_error_message(), 'invalid_url'); } else { EE_Registry::instance()->load_helper('URL'); if (!EEH_URL::remote_file_exists($normalized_value)) { throw new EE_Validation_Error(sprintf(__("That URL seems to be broken. Please enter a valid URL", "event_espresso"))); } } } }
/** * Callback for FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg for adding * helpful title. * * @param string $content Current content * @param string $page_slug Page slug for page * @param array $req_data Incoming request data * @param string $req_action 'action' value for page * * @return string If correct page and conditions are met, the new string. Otherwise existing string. */ public static function before_events_list_table_content($content, $page_slug, $req_data, $req_action) { if ($page_slug !== 'espresso_events' || $req_action !== 'default' || empty($req_data['TXN_ID'])) { return $content; } $transaction = EEM_Transaction::instance()->get_one_by_ID($req_data['TXN_ID']); if ($transaction instanceof EE_Transaction) { $query_args = array('page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $req_data['TXN_ID']); EE_Registry::instance()->load_helper('URL'); $url = EEH_URL::add_query_args_and_nonce($query_args, admin_url('admin.php')); $link_text = '<a href="' . $url . '">' . $transaction->ID() . '</a>'; $content .= '<h2>' . sprintf(__('Events Registered for in Transaction # %s', 'event_espresso'), $link_text) . '</h2>'; } return $content; }
/** * default maintenance page. If we're in maintenance mode level 2, then we need to show * the migration scripts and all that UI. */ public function _maintenance() { //it all depends if we're in maintenance model level 1 (frontend-only) or //level 2 (everything except maintenance page) try { //get the current maintenance level and check if //we are removed $mm = EE_Maintenance_Mode::instance()->level(); $placed_in_mm = EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); if ($mm == EE_Maintenance_Mode::level_2_complete_maintenance && !$placed_in_mm) { //we just took the site out of maintenance mode, so notify the user. //unfortunately this message appears to be echoed on the NEXT page load... //oh well, we should really be checking for this on addon deactivation anyways EE_Error::add_attention(__('Site taken out of maintenance mode because no data migration scripts are required', 'event_espresso')); $this->_process_notices(array('page' => 'espresso_maintenance_settings'), false); } //in case an exception is thrown while trying to handle migrations switch (EE_Maintenance_Mode::instance()->level()) { case EE_Maintenance_Mode::level_0_not_in_maintenance: case EE_Maintenance_Mode::level_1_frontend_only_maintenance: $show_maintenance_switch = true; $show_backup_db_text = false; $show_migration_progress = false; $script_names = array(); $addons_should_be_upgraded_first = false; break; case EE_Maintenance_Mode::level_2_complete_maintenance: $show_maintenance_switch = false; $show_migration_progress = true; if (isset($this->_req_data['continue_migration'])) { $show_backup_db_text = false; } else { $show_backup_db_text = true; } $scripts_needing_to_run = EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts(); $addons_should_be_upgraded_first = EE_Data_Migration_Manager::instance()->addons_need_updating(); $script_names = array(); $current_script = NULL; foreach ($scripts_needing_to_run as $script) { if ($script instanceof EE_Data_Migration_Script_Base) { if (!$current_script) { $current_script = $script; $current_script->migration_page_hooks(); } $script_names[] = $script->pretty_name(); } } break; } $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true); $exception_thrown = false; } catch (EE_Error $e) { EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage()); //now, just so we can display the page correctly, make a error migration script stage object //and also put the error on it. It only persists for the duration of this request $most_recent_migration = new EE_DMS_Unknown_1_0_0(); $most_recent_migration->add_error($e->getMessage()); $exception_thrown = true; } $current_db_state = EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set(); if ($exception_thrown || $most_recent_migration && $most_recent_migration instanceof EE_Data_Migration_Script_Base && $most_recent_migration->is_broken()) { $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php'; $this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/'; $this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action' => 'confirm_migration_crash_report_sent', 'success' => '0'), EE_MAINTENANCE_ADMIN_URL); } elseif ($addons_should_be_upgraded_first) { $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php'; } else { if ($most_recent_migration && $most_recent_migration instanceof EE_Data_Migration_Script_Base && $most_recent_migration->can_continue()) { $show_backup_db_text = false; $show_continue_current_migration_script = true; $show_most_recent_migration = true; } elseif (isset($this->_req_data['continue_migration'])) { $show_most_recent_migration = true; $show_continue_current_migration_script = false; } else { $show_most_recent_migration = false; $show_continue_current_migration_script = false; } if (isset($current_script)) { $migrates_to = $current_script->migrates_to_version(); $plugin_slug = $migrates_to['slug']; $new_version = $migrates_to['version']; $this->_template_args = array_merge($this->_template_args, array('current_db_state' => sprintf(__("EE%s (%s)", "event_espresso"), isset($current_db_state[$plugin_slug]) ? $current_db_state[$plugin_slug] : 3, $plugin_slug), 'next_db_state' => isset($current_script) ? sprintf(__("EE%s (%s)", 'event_espresso'), $new_version, $plugin_slug) : NULL)); } $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php'; $this->_template_args = array_merge($this->_template_args, array('show_most_recent_migration' => $show_most_recent_migration, 'show_migration_progress' => $show_migration_progress, 'show_backup_db_text' => $show_backup_db_text, 'show_maintenance_switch' => $show_maintenance_switch, 'script_names' => $script_names, 'show_continue_current_migration_script' => $show_continue_current_migration_script, 'reset_db_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'), EE_MAINTENANCE_ADMIN_URL), 'update_migration_script_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'change_maintenance_level'), EE_MAINTENANCE_ADMIN_URL), 'ultimate_db_state' => sprintf(__("EE%s", 'event_espresso'), espresso_version()))); //make sure we have the form fields helper available. It usually is, but sometimes it isn't EE_Registry::instance()->load_helper('Form_Fields'); //localize script stuff wp_localize_script('ee-maintenance', 'ee_maintenance', array('migrating' => __("Migrating...", "event_espresso"), 'next' => __("Next", "event_espresso"), 'fatal_error' => __("A Fatal Error Has Occurred", "event_espresso"), 'click_next_when_ready' => __("The current Migration has ended. Click 'next' when ready to proceed", "event_espresso"), 'status_no_more_migration_scripts' => EE_Data_Migration_Manager::status_no_more_migration_scripts, 'status_fatal_error' => EE_Data_Migration_Manager::status_fatal_error, 'status_completed' => EE_Data_Migration_Manager::status_completed)); } $this->_template_args['most_recent_migration'] = $most_recent_migration; //the actual most recently ran migration $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, $this->_template_args, TRUE); $this->display_admin_page_with_sidebar(); }
public function column_actions(EE_Promotion $item) { $action_links = array(); EE_Registry::instance()->load_helper('URL'); if ($this->_view != 'trash') { $edit_query_args = array('action' => 'edit', 'PRO_ID' => $item->ID()); $dupe_query_args = array('action' => 'duplicate', 'PRO_ID' => $item->ID()); $edit_link = EEH_URL::add_query_args_and_nonce($edit_query_args, EE_PROMOTIONS_ADMIN_URL); $dupe_link = EEH_URL::add_query_args_and_nonce($dupe_query_args, EE_PROMOTIONS_ADMIN_URL); if (EE_Registry::instance()->CAP->current_user_can('ee_edit_promotion', 'espresso_promotions_edit_promotion', $item->ID())) { $action_links[] = '<a href="' . $edit_link . '" title="' . __('Edit Promotion', 'event_espresso') . '"><div class="dashicons dashicons-edit clickable ee-icon-size-20"></div></a>'; } if (EE_Registry::instance()->CAP->current_user_can('ee_edit_promotion', 'espresso_promotions_edit_promotion', $item->ID())) { $action_links[] = '<a href="' . $dupe_link . '" title="' . __('Duplicate Promotion', 'event_espresso') . '"><div class="ee-icon ee-icon-clone clickable ee-icon-size-16"></div></a>'; } } else { $restore_query_args = array('action' => 'restore_promotion', 'PRO_ID' => $item->ID()); $restore_link = EEH_URL::add_query_args_and_nonce($restore_query_args, EE_PROMOTIONS_ADMIN_URL); if (EE_Registry::instance()->CAP->current_user_can('ee_delete_promotion', 'espresso_promotions_delete_promotion', $item->ID())) { $action_links[] = '<a href="' . $restore_link . '" title="' . __('Restore Promotion', 'event_espresso') . '"><div class="dashicons dashicons-backup ee-icon-size-18"></div></a>'; } } $trash_query_args = array('action' => $this->_view == 'trash' && $item->redeemed() ? 'delete_promotion' : 'trash_promotion', 'PRO_ID' => $item->ID()); $trash_link = EEH_URL::add_query_args_and_nonce($trash_query_args, EE_PROMOTIONS_ADMIN_URL); $trash_text = $this->_view == 'trash' ? __('Delete Promotion permanently', 'event_espresso') : __('Trash Promotion', 'event_espresso'); $trash_class = $this->_view == 'trash' ? ' red-icon' : ''; if (EE_Registry::instance()->CAP->current_user_can('ee_delete_promotion', 'espresso_promotions_delete_promotion', $item->ID())) { $action_links[] = $this->_view == 'trash' && $item->redeemed() > 0 ? '' : '<a href="' . $trash_link . '" title="' . $trash_text . '"><div class="dashicons dashicons-trash clickable ee-icon-size-18' . $trash_class . '"></div></a>'; } $content = '<div style="width:100%;">' . "\n\t"; $content .= implode("\n\t", $action_links); $content .= "\n" . '</div>' . "\n"; echo $content; }
/** * Private constructor to prevent direct creation. * * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and * any incoming timezone data that gets saved). Note this just sends the timezone info to the * date time model field objects. Default is null (and will be assumed using the set timezone * in the 'timezone_string' wp option) * * @return EEM_Message */ protected function __construct($timezone = null) { $this->singular_item = __('Message', 'event_espresso'); $this->plural_item = __('Messages', 'event_espresso'); //used for token generator EE_Registry::instance()->load_helper('URL'); $this->_tables = array('Message' => new EE_Primary_Table('esp_message', 'MSG_ID')); $allowed_priority = array(self::priority_high => __('high', 'event_espresso'), self::priority_medium => __('medium', 'event_espresso'), self::priority_low => __('low', 'event_espresso')); $this->_fields = array('Message' => array('MSG_ID' => new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID', 'event_espresso')), 'MSG_token' => new EE_Plain_Text_Field('MSG_token', __('Unique Token used to represent this row in publicly viewable contexts (eg. a url).', 'event_espresso'), false, EEH_URL::generate_unique_token()), 'GRP_ID' => new EE_Foreign_Key_Int_Field('GRP_ID', __('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso'), true, 0, 'Message_Template_Group'), 'TXN_ID' => new EE_Foreign_Key_Int_Field('TXN_ID', __('Foreign key to the related EE_Transaction. This is required to give context for regenerating the specific message', 'event_espresso'), true, 0, 'Transaction'), 'MSG_messenger' => new EE_Plain_Text_Field('MSG_messenger', __('Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.', 'event_espresso'), false, 'email'), 'MSG_message_type' => new EE_Plain_Text_Field('MSG_message_type', __('Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso'), false, 'receipt'), 'MSG_context' => new EE_Plain_Text_Field('MSG_context', __('Context', 'event_espresso'), false), 'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field('MSG_recipient_ID', __('Recipient ID', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')), 'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field('MSG_recipient_type', __('Recipient Type', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')), 'MSG_content' => new EE_Maybe_Serialized_Text_Field('MSG_content', __('Content', 'event_espresso'), true, ''), 'MSG_to' => new EE_Maybe_Serialized_Text_Field('MSG_to', __('Address To', 'event_espresso'), true), 'MSG_from' => new EE_Maybe_Serialized_Text_Field('MSG_from', __('Address From', 'event_espresso'), true), 'MSG_subject' => new EE_Maybe_Serialized_Text_Field('MSG_subject', __('Subject', 'event_espresso'), true, ''), 'MSG_priority' => new EE_Enum_Integer_Field('MSG_priority', __('Priority', 'event_espresso'), false, self::priority_low, $allowed_priority), 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status', 'event_espresso'), false, self::status_incomplete, 'Status'), 'MSG_created' => new EE_Datetime_Field('MSG_created', __('Created', 'event_espresso'), false, time()), 'MSG_modified' => new EE_Datetime_Field('MSG_modified', __('Modified', 'event_espresso'), true, time()))); $this->_model_relations = array('Attendee' => new EE_Belongs_To_Any_Relation(), 'Registration' => new EE_Belongs_To_Any_Relation(), 'WP_User' => new EE_Belongs_To_Any_Relation(), 'Message_Template_Group' => new EE_Belongs_To_Relation(), 'Transaction' => new EE_Belongs_To_Relation()); parent::__construct($timezone); }
protected function _get_admin_content_events_edit($message_types, $extra) { //defaults $template_args = array(); $custom_templates = array(); $selector_rows = ''; //we don't need message types here so we're just going to ignore. we do, however, expect the event id here. The event id is needed to provide a link to setup a custom template for this event. $event_id = isset($extra['event']) ? $extra['event'] : NULL; $template_wrapper_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_wrapper.template.php'; $template_row_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_row.template.php'; //array of template objects for global and custom (non-trashed) (but remember just for this messenger!) $global_templates = EEM_Message_Template_Group::instance()->get_all(array(array('MTP_messenger' => $this->name, 'MTP_is_global' => TRUE, 'MTP_is_active' => TRUE))); $templates_for_event = EEM_Message_Template_Group::instance()->get_all_custom_templates_by_event($event_id, array('MTP_messenger' => $this->name, 'MTP_is_active' => TRUE)); $templates_for_event = !empty($templates_for_event) ? $templates_for_event : array(); //so we need to setup the rows for the selectors and we use the global mtpgs (cause those will the active message template groups) foreach ($global_templates as $mtpgID => $mtpg) { //verify this message type is supposed to show on this page $mtp_obj = $mtpg->message_type_obj(); if (!$mtp_obj instanceof EE_message_type) { continue; } $mtp_obj->admin_registered_pages = (array) $mtp_obj->admin_registered_pages; if (!in_array('events_edit', $mtp_obj->admin_registered_pages)) { continue; } $stargs = array(); $default_value = ''; $select_values = array(); $select_values[$mtpgID] = __('Global', 'event_espresso'); $default_value = array_key_exists($mtpgID, $templates_for_event) && !$mtpg->get('MTP_is_override') ? $mtpgID : NULL; //if the override has been set for the global template, then that means even if there are custom templates already created we ignore them because of the set override. if (!$mtpg->get('MTP_is_override')) { //any custom templates for this message type? $custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt($this->name, $mtpg->message_type()); foreach ($custom_templates as $cmtpgID => $cmtpg) { $select_values[$cmtpgID] = $cmtpg->name(); $default_value = array_key_exists($cmtpgID, $templates_for_event) ? $cmtpgID : $default_value; } } //if there is no $default_value then we set it as the global $default_value = empty($default_value) ? $mtpgID : $default_value; $edit_url = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value), admin_url('admin.php')); $create_url = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'add_new_message_template', 'GRP_ID' => $default_value), admin_url('admin.php')); $st_args['mt_name'] = ucwords($mtp_obj->label['singular']); $st_args['mt_slug'] = $mtpg->message_type(); $st_args['messenger_slug'] = $this->name; $st_args['selector'] = EEH_Form_Fields::select_input('event_message_templates_relation[' . $mtpgID . ']', $select_values, $default_value, 'data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '"', 'message-template-selector'); //note that message template group that has override_all_custom set will remove the ability to set a custom message template based off of the global (and that also in turn overrides any other custom templates). $st_args['create_button'] = $mtpg->get('MTP_is_override') ? '' : '<a data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $create_url . '" class="button button-small create-mtpg-button">' . __('Create New Custom', 'event_espresso') . '</a>'; $st_args['create_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'espresso_messsages_add_new_message_template') ? $st_args['create_button'] : ''; $st_args['edit_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID) ? '<a data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $edit_url . '" class="button button-small edit-mtpg-button">' . __('Edit', 'event_espresso') . '</a>' : ''; $selector_rows .= EEH_Template::display_template($template_row_path, $st_args, TRUE); } //if no selectors present then get out. if (empty($selector_rows)) { return ''; } $template_args['selector_rows'] = $selector_rows; return EEH_Template::display_template($template_wrapper_path, $template_args, TRUE); }
public function column_PER_event_types($item) { EE_Registry::instance()->load_helper('URL'); //first do a query to get all the types for this user for where they are assigned to an event. $event_type_IDs = EEM_Person_Post::instance()->get_col(array(array('PER_ID' => $item->ID(), 'OBJ_type' => 'Event')), 'PT_ID'); $event_types = EEM_Term_Taxonomy::instance()->get_all(array(array('term_taxonomy_id' => array('IN', $event_type_IDs)))); //loop through the types and setup the pills and the links $content = '<ul class="person-to-cpt-people-type-list">'; foreach ($event_types as $type) { $name = $type->get_first_related('Term')->get('name'); $count = EEM_Person_Post::instance()->count(array(array('PER_ID' => $item->ID(), 'OBJ_type' => 'Event', 'PT_ID' => $type->ID()))); $event_filter_link = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_events', 'action' => 'default', 'PER_ID' => $item->ID(), 'PT_ID' => $type->ID()), admin_url('admin.php')); $content .= '<li><a href="' . $event_filter_link . '">' . $name . '<span class="person-type-count">' . $count . '</span></a></li>'; } $content .= '</ul>'; echo $content; }
/** * Child scope classes indicate what gets returned when the admin_url is requested. * Admin url usually points to the details page for the given id. * * @since 1.0.0 * @param int | EE_Event[] $EVT_ID ID or array of ids for the EE_Event object being utilized * @return string */ public function get_admin_url($EVT_ID) { $base_url = admin_url('admin.php?page=espresso_events'); if (empty($EVT_ID) || is_array($EVT_ID)) { return $base_url; } $query_args = array('action' => 'edit', 'post' => $EVT_ID); EE_Registry::instance()->load_helper('URL'); return EEH_URL::add_query_args_and_nonce($query_args, $base_url); }
/** * Simply generates and returns the appropriate admin_url link to edit this registration * @return string */ public function get_admin_edit_url() { EE_Registry::instance()->load_helper('URL'); return EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_registrations', 'action' => 'view_registration', '_REG_ID' => $this->ID()), admin_url('admin.php')); }
/** * Implementation for EEI_Admin_Links interface method. * @see EEI_Admin_Links for comments * @return string */ public function get_admin_overview_link() { EE_Registry::instance()->load_helper('URL'); return EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_events', 'action' => 'default'), admin_url('admin.php')); }
/** * _add_query_arg * adds nonce to array of arguments then calls WP add_query_arg function *(internally just uses EEH_URL's function with the same name) * @access public * @param array $args * @param string $url * @return string */ public static function add_query_args_and_nonce($args = array(), $url = FALSE) { EE_Registry::instance()->load_helper('URL'); return EEH_URL::add_query_args_and_nonce($args, $url); }
/** * _process_response_url * @return string */ protected function _process_response_url() { if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) { $url = is_ssl() ? 'https://' : 'http://'; $url .= EEH_URL::filter_input_server_url('HTTP_HOST'); $url .= EEH_URL::filter_input_server_url(); } else { $url = 'unknown'; } return $url; }
/** * Implementation for EEI_Admin_Links interface method. * @see EEI_Admin_Links for comments * @return string */ public function get_admin_overview_link() { return EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_events', 'action' => 'default'), admin_url('admin.php')); }
echo $EVT_ID; ?> []" value="1"/> <input type="hidden" name="tkt-slctr-ticket-id-<?php echo $EVT_ID; ?> []" value="<?php echo $TKT_ID; ?> "/> <input type="hidden" name="noheader" value="true"/> <input type="hidden" name="tkt-slctr-return-url-<?php echo $EVT_ID; ?> " value="<?php echo EEH_URL::filter_input_server_url(); ?> "/> <input type="hidden" name="tkt-slctr-rows-<?php echo $EVT_ID; ?> " value="<?php echo $row - 1; ?> "/> <input type="hidden" name="tkt-slctr-max-atndz-<?php echo $EVT_ID; ?> " value="<?php echo $max_atndz; ?>
/** * ticket_selector_form_open * * @access public * @param int $ID * @param string $external_url * @return string */ public static function ticket_selector_form_open($ID = 0, $external_url = '') { // if redirecting, we don't need any anything else if ($external_url) { EE_Registry::instance()->load_helper('URL'); $html = '<form id="" method="GET" action="' . EEH_URL::refactor_url($external_url) . '">'; $query_args = EEH_URL::get_query_string($external_url); foreach ($query_args as $query_arg => $value) { $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; } return $html; } EE_Registry::instance()->load_helper('Event_View'); $checkout_url = EEH_Event_View::event_link_url($ID); if (!$checkout_url) { $msg = __('The URL for the Event Details page could not be retrieved.', 'event_espresso'); EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); } $checkout_url = add_query_arg(array('ee' => 'process_ticket_selections'), $checkout_url); return '<form id="" method="POST" action="' . $checkout_url . '">' . wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE); }
/** * This returns all the current urls for EE_Message actions. * * @since 4.9.0 * * @param EE_Message $message The EE_Message object required to generate correct urls for some types. * @param array $query_params Any additional query_params to be included with the generated url. * * @return array */ public static function get_message_action_urls(EE_Message $message = null, $query_params = array()) { EE_Registry::instance()->load_helper('URL'); //if $message is not an instance of EE_Message then let's just do a dummy. $message = empty($message) ? EE_Message_Factory::create() : $message; $action_urls = apply_filters('FHEE__EEH_MSG_Template__get_message_action_url', array('view' => EEH_MSG_Template::generate_browser_trigger($message), 'error' => EEH_MSG_Template::generate_error_display_trigger($message), 'see_notifications_for' => EEH_URL::add_query_args_and_nonce(array_merge(array('page' => 'espresso_messages', 'action' => 'default', 'filterby' => 1), $query_params), admin_url('admin.php')), 'generate_now' => EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'generate_now', 'MSG_ID' => $message->ID()), admin_url('admin.php')), 'send_now' => EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'send_now', 'MSG_ID' => $message->ID()), admin_url('admin.php')), 'queue_for_resending' => EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'queue_for_resending', 'MSG_ID' => $message->ID()), admin_url('admin.php')))); if ($message->TXN_ID() > 0 && EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_default', $message->TXN_ID())) { $action_urls['view_transaction'] = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $message->TXN_ID()), admin_url('admin.php')); } else { $action_urls['view_transaction'] = ''; } return $action_urls; }
/** * Callback for setting up the people type metaboxes. * * @param WP_Post $post * @param array $metabox_args * * @return string Metabox Content */ public function people_type_metabox($post, $metabox_args) { $incoming_args = $metabox_args['args']; $people_type = $incoming_args['people_type']; //if we don't have a valid people type then get out early! if (!$people_type instanceof EE_Term_Taxonomy) { return; } EE_Registry::instance()->load_helper('Template'); EE_Registry::instance()->load_helper('URL'); $type_order_query = array('order_by' => 'Person_Post.PER_OBJ_order'); $template_args = array('people_type' => $people_type, 'type' => $people_type->get_first_related('Term'), 'people' => $this->_get_people($type_order_query), 'assigned_people' => EE_Registry::instance()->load_model('Person')->get_people_for_event_and_type($post->ID, $people_type->get('term_taxonomy_id')), 'create_person_link' => EEH_URL::add_query_args_and_nonce(array('action' => 'create_new'), EEA_PEOPLE_ADDON_ADMIN_URL)); $template = EEA_PEOPLE_ADDON_PATH . 'admin/people/templates/people_type_event_metabox_details.template.php'; EEH_Template::display_template($template, $template_args); }
/** * Use this to edit the post link for our cpts so that the edit link points to the correct page. * * @since 4.3.0 * * @param string $link the original link generated by wp * @param int $id post id * @param string $context optional, defaults to display. How to write the '&' * * @return string the (maybe) modified link */ public function modify_edit_post_link($link, $id, $context) { if (!($post = get_post($id))) { return $link; } if ($post->post_type == 'espresso_attendees') { $query_args = array('action' => 'edit_attendee', 'post' => $id); EE_Registry::instance()->load_helper('URL'); return EEH_URL::add_query_args_and_nonce($query_args, admin_url('admin.php?page=espresso_registrations')); } return $link; }
/** * Test the filter callback for get_edit_post_link * * @since 4.3.0 * @depends test_loading_admin */ function test_modify_edit_post_link() { //add contact post $attendee = EE_Attendee::new_instance(array('ATT_full_name' => 'Test Dude')); $attendee->save(); $id = $attendee->ID(); //dummy link for testing $orig_link = 'http://testdummylink.com'; EE_Registry::instance()->load_helper('URL'); $expected_link = EEH_URL::add_query_args_and_nonce(array('action' => 'edit_attendee', 'post' => $id), admin_url('admin.php?page=espresso_registrations')); //first test that if the id given doesn't match our post type that the original link is returned. $notmodified = EE_Admin::instance()->modify_edit_post_link($orig_link, 5555, ''); $this->assertEquals($orig_link, $notmodified); //next test that if the id given matches our post type that the expected link is generated $ismodified = EE_Admin::instance()->modify_edit_post_link($orig_link, $id, ''); $this->assertEquals($expected_link, $ismodified); }
/** * ticket_selector_form_open * * @access public * @param int $ID * @param string $external_url * @return string */ public static function ticket_selector_form_open($ID = 0, $external_url = '') { // if redirecting, we don't need any anything else if ($external_url) { $html = '<form method="GET" action="' . EEH_URL::refactor_url($external_url) . '">'; $query_args = EEH_URL::get_query_string($external_url); foreach ($query_args as $query_arg => $value) { $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; } return $html; } $checkout_url = EEH_Event_View::event_link_url($ID); if (!$checkout_url) { EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); } $extra_params = self::$_in_iframe ? ' target="_blank"' : ''; $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>'; $html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE); $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; $html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event); return $html; }
/** * _add_query_arg * adds nonce to array of arguments then calls WP add_query_arg function *(internally just uses EEH_URL's function with the same name) * @access public * @param array $args * @param string $url * @param bool $sticky if true, then the existing Request params will be appended to the generated * url in an associative array indexed by the key 'wp_referer'; * Example usage: * * If the current page is: * http://mydomain.com/wp-admin/admin.php?page=espresso_registrations * &action=default&event_id=20&month_range=March%202015 * &_wpnonce=5467821 * * and you call: * * EE_Admin_Page::add_query_args_and_nonce( * array( * 'action' => 'resend_something', * 'page=>espresso_registrations' * ), * $some_url, * true * ); * * It will produce a url in this structure: * * http://{$some_url}/?page=espresso_registrations&action=resend_something * &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[ * month_range]=March%202015 * @return string */ public static function add_query_args_and_nonce($args = array(), $url = false, $sticky = false) { EE_Registry::instance()->load_helper('URL'); //if there is a _wp_http_referer include the values from the request but only if sticky = true if ($sticky) { $request = $_REQUEST; unset($request['_wp_http_referer']); unset($request['wp_referer']); foreach ($request as $key => $value) { //do not add nonces if (strpos($key, 'nonce') !== false) { continue; } $args['wp_referer[' . $key . ']'] = $value; } } return EEH_URL::add_query_args_and_nonce($args, $url); }
/** * Verifies the button urls on all the passed payment methods have a valid button url. If not, resets them to their default. * @param EE_Payment_Method[] $payment_methods. If NULL is provided defaults to all payment methods active in the cart */ function verify_button_urls($payment_methods = NULL) { EE_Registry::instance()->load_helper('URL'); $payment_methods = is_array($payment_methods) ? $payment_methods : $this->get_all_active(EEM_Payment_Method::scope_cart); foreach ($payment_methods as $payment_method) { try { $current_button_url = $payment_method->button_url(); $buttons_urls_to_try = apply_filters('FHEE__EEM_Payment_Method__verify_button_urls__button_urls_to_try', array('current_ssl' => str_replace("http://", "https://", $current_button_url), 'current' => str_replace("https://", "http://", $current_button_url), 'default_ssl' => str_replace("http://", "https://", $payment_method->type_obj()->default_button_url()), 'default' => str_replace("https://", "http://", $payment_method->type_obj()->default_button_url()))); foreach ($buttons_urls_to_try as $button_url_to_try) { if ($button_url_to_try == $current_button_url && EEH_URL::remote_file_exists($button_url_to_try, array('sslverify' => false, 'limit_response_size' => 4095)) || $button_url_to_try != $current_button_url && EEH_URL::remote_file_exists($button_url_to_try)) { if ($current_button_url != $button_url_to_try) { $payment_method->save(array('PMD_button_url' => $button_url_to_try)); EE_Error::add_attention(sprintf(__("Payment Method %s's button url was set to %s, because the old image either didnt exist or SSL was recently enabled.", "event_espresso"), $payment_method->name(), $button_url_to_try)); } //this image exists. So if wasn't set before, now it is; //or if it was already set, we have nothing to do break; } } } catch (EE_Error $e) { $payment_method->set_active(FALSE); } } }
/** * @param EE_Message $message * @return string The recipient of the message * @throws \EE_Error */ public function column_to(EE_Message $message) { EE_Registry::instance()->load_helper('URL'); $actions = array(); $actions['delete'] = '<a href="' . EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'delete_ee_message', 'MSG_ID' => $message->ID()), admin_url('admin.php')) . '">' . __('Delete', 'event_espresso') . '</a>'; return $message->to() . $this->row_actions($actions); }
/** * espresso_toolbar_items * * @access public * @param WP_Admin_Bar $admin_bar * @return void */ public function espresso_toolbar_items(WP_Admin_Bar $admin_bar) { // if in full M-Mode, or its an AJAX request, or user is NOT an admin if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined('DOING_AJAX') || !$this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level')) { return; } do_action('AHEE_log', __FILE__, __FUNCTION__, ''); $menu_class = 'espresso_menu_item_class'; //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL //because they're only defined in each of their respective constructors //and this might be a frontend request, in which case they aren't available $events_admin_url = admin_url("admin.php?page=espresso_events"); $reg_admin_url = admin_url("admin.php?page=espresso_registrations"); $extensions_admin_url = admin_url("admin.php?page=espresso_packages"); //Top Level $admin_bar->add_menu(array('id' => 'espresso-toolbar', 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') . '</span>', 'href' => $events_admin_url, 'meta' => array('title' => __('Event Espresso', 'event_espresso'), 'class' => $menu_class . 'first'))); //Events if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) { $admin_bar->add_menu(array('id' => 'espresso-toolbar-events', 'parent' => 'espresso-toolbar', 'title' => __('Events', 'event_espresso'), 'href' => $events_admin_url, 'meta' => array('title' => __('Events', 'event_espresso'), 'target' => '', 'class' => $menu_class))); } if ($this->registry->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) { //Events Add New $admin_bar->add_menu(array('id' => 'espresso-toolbar-events-new', 'parent' => 'espresso-toolbar-events', 'title' => __('Add New', 'event_espresso'), 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'create_new'), $events_admin_url), 'meta' => array('title' => __('Add New', 'event_espresso'), 'target' => '', 'class' => $menu_class))); } if (is_single() && get_post_type() == 'espresso_events') { //Current post global $post; if ($this->registry->CAP->current_user_can('ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID)) { //Events Edit Current Event $admin_bar->add_menu(array('id' => 'espresso-toolbar-events-edit', 'parent' => 'espresso-toolbar-events', 'title' => __('Edit Event', 'event_espresso'), 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'edit', 'post' => $post->ID), $events_admin_url), 'meta' => array('title' => __('Edit Event', 'event_espresso'), 'target' => '', 'class' => $menu_class))); } } //Events View if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view')) { $admin_bar->add_menu(array('id' => 'espresso-toolbar-events-view', 'parent' => 'espresso-toolbar-events', 'title' => __('View', 'event_espresso'), 'href' => $events_admin_url, 'meta' => array('title' => __('View', 'event_espresso'), 'target' => '', 'class' => $menu_class))); } if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) { //Events View All $admin_bar->add_menu(array('id' => 'espresso-toolbar-events-all', 'parent' => 'espresso-toolbar-events-view', 'title' => __('All', 'event_espresso'), 'href' => $events_admin_url, 'meta' => array('title' => __('All', 'event_espresso'), 'target' => '', 'class' => $menu_class))); } if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today')) { //Events View Today $admin_bar->add_menu(array('id' => 'espresso-toolbar-events-today', 'parent' => 'espresso-toolbar-events-view', 'title' => __('Today', 'event_espresso'), 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), $events_admin_url), 'meta' => array('title' => __('Today', 'event_espresso'), 'target' => '', 'class' => $menu_class))); } if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month')) { //Events View This Month $admin_bar->add_menu(array('id' => 'espresso-toolbar-events-month', 'parent' => 'espresso-toolbar-events-view', 'title' => __('This Month', 'event_espresso'), 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), $events_admin_url), 'meta' => array('title' => __('This Month', 'event_espresso'), 'target' => '', 'class' => $menu_class))); } //Registration Overview if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations')) { $admin_bar->add_menu(array('id' => 'espresso-toolbar-registrations', 'parent' => 'espresso-toolbar', 'title' => __('Registrations', 'event_espresso'), 'href' => $reg_admin_url, 'meta' => array('title' => __('Registrations', 'event_espresso'), 'target' => '', 'class' => $menu_class))); } //Registration Overview Today if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today')) { $admin_bar->add_menu(array('id' => 'espresso-toolbar-registrations-today', 'parent' => 'espresso-toolbar-registrations', 'title' => __('Today', 'event_espresso'), 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), $reg_admin_url), 'meta' => array('title' => __('Today', 'event_espresso'), 'target' => '', 'class' => $menu_class))); } //Registration Overview Today Completed if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved')) { $admin_bar->add_menu(array('id' => 'espresso-toolbar-registrations-today-approved', 'parent' => 'espresso-toolbar-registrations-today', 'title' => __('Approved', 'event_espresso'), 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today', '_reg_status' => EEM_Registration::status_id_approved), $reg_admin_url), 'meta' => array('title' => __('Approved', 'event_espresso'), 'target' => '', 'class' => $menu_class))); } //Registration Overview Today Pending\ if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending')) { $admin_bar->add_menu(array('id' => 'espresso-toolbar-registrations-today-pending', 'parent' => 'espresso-toolbar-registrations-today', 'title' => __('Pending', 'event_espresso'), 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today', 'reg_status' => EEM_Registration::status_id_pending_payment), $reg_admin_url), 'meta' => array('title' => __('Pending Payment', 'event_espresso'), 'target' => '', 'class' => $menu_class))); } //Registration Overview Today Incomplete if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved')) { $admin_bar->add_menu(array('id' => 'espresso-toolbar-registrations-today-not-approved', 'parent' => 'espresso-toolbar-registrations-today', 'title' => __('Not Approved', 'event_espresso'), 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today', '_reg_status' => EEM_Registration::status_id_not_approved), $reg_admin_url), 'meta' => array('title' => __('Not Approved', 'event_espresso'), 'target' => '', 'class' => $menu_class))); } //Registration Overview Today Incomplete if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled')) { $admin_bar->add_menu(array('id' => 'espresso-toolbar-registrations-today-cancelled', 'parent' => 'espresso-toolbar-registrations-today', 'title' => __('Cancelled', 'event_espresso'), 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today', '_reg_status' => EEM_Registration::status_id_cancelled), $reg_admin_url), 'meta' => array('title' => __('Cancelled', 'event_espresso'), 'target' => '', 'class' => $menu_class))); } //Registration Overview This Month if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month')) { $admin_bar->add_menu(array('id' => 'espresso-toolbar-registrations-month', 'parent' => 'espresso-toolbar-registrations', 'title' => __('This Month', 'event_espresso'), 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), $reg_admin_url), 'meta' => array('title' => __('This Month', 'event_espresso'), 'target' => '', 'class' => $menu_class))); } //Registration Overview This Month Approved if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved')) { $admin_bar->add_menu(array('id' => 'espresso-toolbar-registrations-month-approved', 'parent' => 'espresso-toolbar-registrations-month', 'title' => __('Approved', 'event_espresso'), 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month', '_reg_status' => EEM_Registration::status_id_approved), $reg_admin_url), 'meta' => array('title' => __('Approved', 'event_espresso'), 'target' => '', 'class' => $menu_class))); } //Registration Overview This Month Pending if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending')) { $admin_bar->add_menu(array('id' => 'espresso-toolbar-registrations-month-pending', 'parent' => 'espresso-toolbar-registrations-month', 'title' => __('Pending', 'event_espresso'), 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month', '_reg_status' => EEM_Registration::status_id_pending_payment), $reg_admin_url), 'meta' => array('title' => __('Pending', 'event_espresso'), 'target' => '', 'class' => $menu_class))); } //Registration Overview This Month Not Approved if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved')) { $admin_bar->add_menu(array('id' => 'espresso-toolbar-registrations-month-not-approved', 'parent' => 'espresso-toolbar-registrations-month', 'title' => __('Not Approved', 'event_espresso'), 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month', '_reg_status' => EEM_Registration::status_id_not_approved), $reg_admin_url), 'meta' => array('title' => __('Not Approved', 'event_espresso'), 'target' => '', 'class' => $menu_class))); } //Registration Overview This Month Cancelled if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled')) { $admin_bar->add_menu(array('id' => 'espresso-toolbar-registrations-month-cancelled', 'parent' => 'espresso-toolbar-registrations-month', 'title' => __('Cancelled', 'event_espresso'), 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month', '_reg_status' => EEM_Registration::status_id_cancelled), $reg_admin_url), 'meta' => array('title' => __('Cancelled', 'event_espresso'), 'target' => '', 'class' => $menu_class))); } //Extensions & Services if ($this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services')) { $admin_bar->add_menu(array('id' => 'espresso-toolbar-extensions-and-services', 'parent' => 'espresso-toolbar', 'title' => __('Extensions & Services', 'event_espresso'), 'href' => $extensions_admin_url, 'meta' => array('title' => __('Extensions & Services', 'event_espresso'), 'target' => '', 'class' => $menu_class))); } }
/** * _process_response_url * @return string */ protected function _process_response_url() { EE_Registry::instance()->load_helper('URL'); if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) { $url = is_ssl() ? 'https://' : 'http://'; $url .= EEH_URL::filter_input_server_url('HTTP_HOST'); $url .= EEH_URL::filter_input_server_url(); } else { $url = 'unknown'; } return $url; }
protected function _parser($shortcode) { EE_Registry::instance()->load_helper('Formatter'); $this->_event = $this->_data instanceof EE_Event ? $this->_data : null; //if no event, then let's see if there is a reg_obj. If there IS, then we'll try and grab the event from the reg_obj instead. if (empty($this->_event)) { $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : NULL; $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee; $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration ? $aee->reg_obj->event() : NULL; } //If there is no event objecdt by now then get out. if (!$this->_event instanceof EE_Event) { return ''; } switch ($shortcode) { case '[EVENT_ID]': return $this->_event->ID(); break; case '[EVENT_IDENTIFIER]': return isset($this->_data['line_ref']) ? $this->_data['line_ref'] : ''; break; case '[EVENT]': case '[EVENT_NAME]': return $this->_event->get('EVT_name'); break; case '[EVENT_PHONE]': return $this->_event->get('EVT_phone'); break; case '[EVENT_DESCRIPTION]': return $this->_event->get('EVT_desc'); break; case '[EVENT_EXCERPT]': return $this->_event->get('EVT_short_desc'); break; case '[EVENT_LINK]': return $this->_get_event_link($this->_event); break; case '[EVENT_URL]': return $this->_get_event_link($this->_event, FALSE); break; case '[VIRTUAL_URL]': $venue = $this->_event->get_first_related('Venue'); if (empty($venue)) { return ''; } return $venue->get('VNU_virtual_url'); case '[VIRTUAL_PHONE]': $venue = $this->_event->get_first_related('Venue'); if (empty($venue)) { return ''; } return $venue->get('VNU_virtual_phone'); break; case '[EVENT_IMAGE]': $image = $this->_event->feature_image_url(array(600, 300)); // @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned. return !empty($image) ? '<img src="' . $image . '" alt="' . sprintf(esc_attr__('%s Feature Image', 'event_espresso'), $this->_event->get('EVT_name')) . '" />' : ''; break; case '[EVENT_FACEBOOK_URL]': $facebook_url = $this->_event->get_post_meta('event_facebook', true); return empty($facebook_url) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook') : $facebook_url; break; case '[EVENT_TWITTER_URL]': $twitter_url = $this->_event->get_post_meta('event_twitter', true); return empty($twitter_url) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter') : $twitter_url; break; case '[EVENT_AUTHOR_EMAIL]': $author_id = $this->_event->get('EVT_wp_user'); $user_data = get_userdata((int) $author_id); return $user_data->user_email; break; case '[EVENT_TOTAL_SPOTS_TAKEN]': return EEM_Registration::instance()->count(array(array('EVT_ID' => $this->_event->ID(), 'STS_ID' => EEM_Registration::status_id_approved)), 'REG_ID', true); break; case '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]': EE_Registry::instance()->load_helper('URL'); return EEH_URL::add_query_args_and_nonce(array('event_id' => $this->_event->ID(), 'page' => 'espresso_registrations', 'action' => 'default'), admin_url('admin.php'), true); break; } if (strpos($shortcode, '[EVENT_META_*') !== false) { $shortcode = str_replace('[EVENT_META_*', '', $shortcode); $shortcode = trim(str_replace(']', '', $shortcode)); //pull the meta value from the event post $event_meta = $this->_event->get_post_meta($shortcode, true); return !empty($event_meta) ? $this->_event->get_post_meta($shortcode, true) : ''; } if (strpos($shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*') !== false) { $attrs = $this->_get_shortcode_attrs($shortcode); $method = empty($attrs['method']) ? 'current' : $attrs['method']; $method = $method === 'current'; $available = $this->_event->total_available_spaces($method); return $available === INF ? '∞' : $available; } return ''; }
/** * transactions_list_table_total * * @access public * @param string $TXN_total * @param EE_Transaction $transaction * @return string */ public static function transactions_list_table_total($TXN_total = '', EE_Transaction $transaction) { foreach ($transaction->line_items(array(array('OBJ_type' => 'Promotion'))) as $promotion_line_item) { $edit_link = EEH_URL::add_query_args_and_nonce(array('action' => 'edit', 'PRO_ID' => $promotion_line_item->OBJ_ID()), EE_PROMOTIONS_ADMIN_URL); $TXN_total = '<a href="' . $edit_link . '" title="' . __('A Promotion was redeemed during this Transaction. Click to View Promotion', 'event_espresso') . '">' . ' <sup><span class="dashicons dashicons-tag green-icon ee-icon-size-12"></span></sup>' . $TXN_total . '</a>'; break; } return $TXN_total; }