/** * * @see Ai1ec_Connector_Plugin::render_tab_content() * */ public function render_tab_content() { global $ai1ec_view_helper; $this->render_opening_div_of_tab(); $file_input = Ai1ec_Helper_Factory::create_input_instance(); $file_input->set_type('file'); $file_input->set_id(self::NAME_OF_FILE_INPUT); $file_input->set_name(self::NAME_OF_FILE_INPUT); $submit = Ai1ec_Helper_Factory::create_input_instance(); $submit->set_type('submit'); $submit->add_class('button-primary'); $submit->set_name(self::NAME_OF_SUBMIT); $submit->set_id(self::NAME_OF_SUBMIT); $submit->set_value(__('Submit Events', AI1EC_PLUGIN_NAME)); $textarea = Ai1ec_Helper_Factory::create_generic_html_tag('textarea'); $textarea->set_attribute('name', self::NAME_OF_TEXTAREA); $textarea->set_attribute('rows', 6); $textarea->set_id(self::NAME_OF_TEXTAREA); $facebook_tab = Ai1ec_Facebook_Factory::get_facebook_tab_instance(); $category_select = $facebook_tab->create_select_category('ai1ec_file_upload_feed_category'); $message = false; if (isset($this->count)) { $text = __('No events were found', AI1EC_PLUGIN_NAME); if ($this->count > 0) { $text = sprintf(_n('Imported %s event', 'Imported %s events', $this->count, AI1EC_PLUGIN_NAME), $this->count); } $message = Ai1ec_Helper_Factory::create_bootstrap_message_instance($text); } $args = array("category_select" => $category_select, "submit" => $submit, "file_input" => $file_input, "textarea" => $textarea); if (false !== $message) { $args['message'] = $message; } $ai1ec_view_helper->display_admin('plugins/file_upload/file_upload.php', $args); $this->render_closing_div_of_tab(); }
/** * Create the html element used as the UI control for the datepicker button. * The href must keep only active filters. * * @param array $args Populated args for the view * @param int|string|null $initial_date The datepicker's initially set date * @return Ai1ec_Generic_Html_Tag */ public static function create_datepicker_link(array $args, $initial_date = null) { global $ai1ec_settings, $ai1ec_view_helper; $link = Ai1ec_Helper_Factory::create_generic_html_tag('a'); $date_format_pattern = Ai1ec_Time_Utility::get_date_pattern_by_key($ai1ec_settings->input_date_format); if ($initial_date == null) { // If exact_date argument was provided, use its value to initialize // datepicker. if (isset($args['exact_date']) && $args['exact_date'] !== false && $args['exact_date'] !== null) { $initial_date = $args['exact_date']; } else { $initial_date = Ai1ec_Time_Utility::gmt_to_local(Ai1ec_Time_Utility::current_time()); } } // Convert initial date to formatted date if required. if (Ai1ec_Validation_Utility::is_valid_time_stamp($initial_date)) { $initial_date = Ai1ec_Time_Utility::format_date(Ai1ec_Time_Utility::gmt_to_local($initial_date), $ai1ec_settings->input_date_format); } $link->add_class('ai1ec-minical-trigger btn'); $link->set_attribute('data-date', $initial_date); $link->set_attribute('data-date-format', $date_format_pattern); $link->set_attribute('data-date-weekstart', $ai1ec_settings->week_start_day); $link->set_attribute_expr($args['data_type']); $text = '<img src="' . esc_attr($ai1ec_view_helper->get_theme_img_url('date-icon.png')) . '" class="ai1ec-icon-datepicker" />'; $link->set_text($text); $href_args = array('action' => $args['action'], 'cat_ids' => $args['cat_ids'], 'tag_ids' => $args['tag_ids'], 'exact_date' => "__DATE__"); $data_href = self::create_href_helper_instance($href_args); $link->set_attribute('data-href', $data_href->generate_href()); $link->set_attribute('href', '#'); return $link; }
/** * * @return Ai1ec_Generic_Html_Tag */ public static function create_refresh_token_button() { $timely = Ai1ec_Helper_Factory::create_generic_html_tag('div'); $timely->add_class('timely ai1ec_refresh_tokens'); $refresh_tokens = Ai1ec_Helper_Factory::create_generic_html_tag('button'); $refresh_tokens->set_id('ai1ec_refresh_tokens'); $refresh_tokens->add_class('btn'); $refresh_tokens->set_text(__("Refresh page tokens", AI1EC_PLUGIN_NAME)); $timely->add_renderable_children($refresh_tokens); return $timely; }
/** * * @see Ai1ec_Renderable::render() * */ public function render() { $input = Ai1ec_Helper_Factory::create_input_instance(); $input->set_name($this->id); $input->set_id($this->id); $input->add_class('input-mini'); $input->add_class('ai1ec-less-variable-size'); $input->set_value($this->value); $input->set_attribute('placeholder', __('Length', AI1EC_PLUGIN_NAME)); echo $this->render_opening_of_control_group(); $input->render(); echo $this->render_closing_of_control_group(); }
/** * * @see Ai1ec_Renderable::render() * */ public function render() { $label = Ai1ec_Helper_Factory::create_generic_html_tag('label'); $label->set_attribute('for', $this->id); $label->add_class('radio'); $label->set_text($this->label); $label->set_prepend_text(false); $radio = Ai1ec_Helper_Factory::create_input_instance(); $radio->set_type('radio'); $radio->set_id($this->id); $radio->set_value($this->id); $radio->set_name($this->name); if (isset($this->args['checked'])) { $radio->set_attribute('checked', 'checked'); } $label->add_renderable_children($radio); $label->render(); }
/** * (non-PHPdoc) * @see Ai1ec_Less_Variable::render() */ public function render() { $input = Ai1ec_Helper_Factory::create_input_instance(); $input->set_name($this->id . self::CUSTOM_FONT_ID_SUFFIX); $input->set_id($this->id . self::CUSTOM_FONT_ID_SUFFIX); if ($this->value !== self::CUSTOM_FONT) { $input->add_class('hide'); } else { $input->set_value($this->custom_value); } $input->add_class('ai1ec-custom-font'); $input->set_attribute('placeholder', __("Enter custom font(s)", AI1EC_PLUGIN_NAME)); echo $this->render_opening_of_control_group(); $this->renderable->render(); echo ' '; // Required for adequate spacing between <select> and <input>. $input->render(); echo $this->render_closing_of_control_group(); }
/** * * @see Ai1ec_Renderable::render() * */ public function render() { $select = Ai1ec_Helper_Factory::create_generic_html_tag('select'); $select->set_id($this->id); foreach ($this->attributes as $name => $value) { $select->set_attribute($name, $value); } foreach ($this->classes as $class) { $select->add_class($class); } foreach ($this->options as $option) { $value = $option->get_attribute('value'); if (isset($this->values[$value[0]])) { $option->set_attribute('selected', 'selected'); } $select->add_renderable_children($option); } $select->render(); }
public function render() { $close = Ai1ec_Helper_Factory::create_generic_html_tag('a'); $close->set_attribute('data-dismiss', 'alert'); $close->add_class('close'); $close->set_attribute('href', '#'); $close->set_text('x'); $container = Ai1ec_Helper_Factory::create_generic_html_tag('div'); $container->add_class('alert'); switch ($this->type) { case "success": $container->add_class('alert-success'); break; case "error": $container->add_class('alert-error'); break; default: break; } $container->set_prepend_text(false); $container->set_text($this->message); $container->add_renderable_children($close); $container->render(); }
/** * Adds al the elements to the page. * I took this out of the factory so that it's done only if the page is clicked */ private function add_renderables_to_page() { // These are the tabs $tabs_ids_description = array('general' => __('General', AI1EC_PLUGIN_NAME), 'table' => __('Tables', AI1EC_PLUGIN_NAME), 'buttons' => __('Buttons', AI1EC_PLUGIN_NAME), 'forms' => __('Forms', AI1EC_PLUGIN_NAME), 'calendar' => __('Calendar general', AI1EC_PLUGIN_NAME), 'posterboard' => __('Posterboard view', AI1EC_PLUGIN_NAME), 'stream' => __('Stream view', AI1EC_PLUGIN_NAME), 'month' => __('Month/week/day view', AI1EC_PLUGIN_NAME), 'agenda' => __('Agenda view', AI1EC_PLUGIN_NAME)); // Create the tab layout $bootstrap_tabs_layout = Ai1ec_Helper_Factory::create_bootstrap_tabs_layout_instance(); $bootstrap_tabs_layout->set_layout('left'); $less_variables = Ai1ec_Lessphp_Controller::get_saved_variables(Ai1ec_Adapters_Factory::create_db_adapter_instance()); // Inizialize the array of tabs that will be added to the layout $bootstrap_tabs_to_add = array(); // initialize the array of tab bodyes that will be added to the tabs $tabs_bodies = array(); foreach ($tabs_ids_description as $id => $description) { $bootstrap_tabs_to_add["ai1ec-{$id}"] = Ai1ec_Helper_Factory::create_bootstrap_tab_instance($id, $description); $bootstrap_tabs_to_add["ai1ec-{$id}"]->add_class('form-horizontal'); // create the main div that will hold all the variables $div = Ai1ec_Helper_Factory::create_generic_html_tag('div'); $tabs_bodies["ai1ec-{$id}"] = $div; } foreach ($less_variables as $variable_id => $variable_attributes) { $variable_attributes['id'] = $variable_id; $less_variable = Ai1ec_Less_Factory::create_less_variable($variable_attributes['type'], $variable_attributes); $tabs_bodies["ai1ec-{$variable_attributes['tab']}"]->add_renderable_children($less_variable); } foreach ($tabs_bodies as $tab => $div) { $bootstrap_tabs_to_add[$tab]->add_renderable_children($div); } foreach ($bootstrap_tabs_to_add as $tab) { $bootstrap_tabs_layout->add_renderable_children($tab); } $this->add_renderable_children($bootstrap_tabs_layout); $input = Ai1ec_Helper_Factory::create_input_instance(); $input->set_type('submit'); $input->set_value(__('Save Options', AI1EC_PLUGIN_NAME)); $input->set_name(Ai1ec_Less_Variables_Editing_Page::FORM_SUBMIT_NAME); $input->add_class("button-primary"); $reset_theme = Ai1ec_Helper_Factory::create_input_instance(); $reset_theme->set_type('submit'); $reset_theme->set_value(__('Reset to defaults', AI1EC_PLUGIN_NAME)); $reset_theme->set_name(Ai1ec_Less_Variables_Editing_Page::FORM_SUBMIT_RESET_THEME); $reset_theme->add_class("button"); $reset_theme->set_id('ai1ec-reset-variables'); $this->add_renderable_children($input); $this->add_renderable_children($reset_theme); }
/** * @param string $type * @param array $params * @return Ai1ec_Less_Variable */ public static function create_less_variable($type, array $params) { switch ($type) { case 'color': $bootstrap_colorpicker = Ai1ec_Helper_Factory::create_bootstrap_colorpicker_instance($params['value'], $params['id']); return new Ai1ec_Less_Variable_Color($params, $bootstrap_colorpicker); break; case 'font': $select = Ai1ec_Helper_Factory::create_select_instance($params['id']); return new Ai1ec_Less_Variable_Font($params, $select); break; } }
public function __construct($params) { $bootstrap_colorpicker = Ai1ec_Helper_Factory::create_bootstrap_colorpicker_instance($params['value'], $params['id']); parent::__construct($params); $this->renderable = $this->set_up_renderable($bootstrap_colorpicker); }
/** * If it is detected that current theme is in legacy format, generate a * dashboard notice. */ public function generate_notice_if_legacy_theme_installed($display_now = false) { $theme = Ai1ec_Meta::get_option('ai1ec_template', AI1EC_DEFAULT_THEME_NAME); // Save directory separator to more concise variable name. $slash = DIRECTORY_SEPARATOR; $errors = array(); // ========================== // = Wrong style.css format = // ========================== // Check if a theme has a style.css file containing something besides a CSS // comment. try { $style = Ai1ec_Less_Factory::create_less_file_instance('..' . $slash . 'style'); $css = file_get_contents($style->locate_exact_file_to_load_in_theme_folders()); } catch (Ai1ec_File_Not_Found $e) { // File not found; no legacy theme code available to detect, so return. return; } $css = $this->remove_comments_and_space($css); if ($css) { $errors[] = sprintf(__('In your theme folder, <code>%s</code>, the file <code>%sstyle.css</code> should now be used only for metadata information (name, author, etc.).', AI1EC_PLUGIN_NAME) . ' ' . __('We detected custom CSS rules in that file. Those should be removed from <code>%sstyle.css</code> and placed in the file <code>%scss%soverride.css</code>.', AI1EC_PLUGIN_NAME), $theme, $slash, $slash, $slash, $slash); } // ========================== // = Required files missing = // ========================== // Check if the theme is missing any of the files that are in Gamma (which // includes the minimum files). $gamma_files = $this->_get_file_listing(AI1EC_THEMES_ROOT . $slash . 'gamma', '#' . $slash . '\\.|^' . $slash . 'functions\\.php$#i'); $theme_files = $this->_get_file_listing($this->active_template_path()); $diff = array_diff($gamma_files, $theme_files); if ($diff) { $errors[] = sprintf(__('Your theme folder <code>%s</code> is missing one or more required files: <code>%s</code>. Please copy these files from the skeleton theme folder, <code>gamma</code>, into the same relative location under <code>%s</code>.', AI1EC_PLUGIN_NAME), $theme, implode('</code>, <code>', $diff), $theme); } if ($errors) { // =============================================================== // = Additional checks for modified page templates and other CSS = // =============================================================== // Now that we've established that the theme is outdated, make certain // recommendations to the user based on the below checks. // If they also have overridden page templates. These *must* be updated. $vortex_php = $this->_get_file_listing(AI1EC_THEMES_ROOT . '/' . AI1EC_DEFAULT_THEME_NAME, '#^' . $slash . '(functions|index)\\.php$#i', '#\\.php$#i'); $theme_php = $this->_get_file_listing($this->active_template_path(), '#^' . $slash . '(functions|index)\\.php$#i', '#\\.php$#i'); $php_in_common = array_intersect($vortex_php, $theme_php); if ($php_in_common) { $errors[] = sprintf(__('We detected one or more custom templates files in your theme folder, <code>%s</code>:', AI1EC_PLUGIN_NAME) . ' ' . '<blockquote><code>' . implode('</code>, <code>', $php_in_common) . '</code></blockquote>' . __('These templates’ originals have changed significantly since these were copied from <code>%s</code>, and the new versions include numerous enhancements. <strong>Your theme’s outdated templates will likely cause your calendar to malfunction.</strong>', AI1EC_PLUGIN_NAME) . ' ' . __('We recommend you back up your templates and remove them from <code>%s</code>. Try using your calendar, and if changes are needed, copy the latest version of the template from <code>%s</code> to <code>%s</code> and then make your revisions.', AI1EC_PLUGIN_NAME), $theme, AI1EC_DEFAULT_THEME_NAME, $theme, AI1EC_DEFAULT_THEME_NAME, $theme); } // Check for overridden CSS. These must also be updated. $vortex_css = array($slash . 'less' . $slash . 'style.less', $slash . 'less' . $slash . 'calendar.less', $slash . 'less' . $slash . 'event.less', $slash . 'css' . $slash . 'style.css', $slash . 'css' . $slash . 'calendar.css', $slash . 'css' . $slash . 'event.css'); $theme_css = $this->_get_file_listing($this->active_template_path(), '#^' . $slash . 'style\\.css$#i', '#\\.(css|less)$#i'); $css_in_common = array_intersect($vortex_css, $theme_css); if ($css_in_common) { $errors[] = sprintf(__('We detected one or more custom CSS or LESS files in your theme folder, <code>%s</code>, that will override the corresponding original in %s:', AI1EC_PLUGIN_NAME) . '<blockquote><code>' . implode('</code>, <code>', $css_in_common) . '</code></blockquote>' . __('The originals have changed significantly since these were copied from <code>%s</code>, and the new versions include numerous enhancements. <strong>Your theme’s outdated CSS/LESS files will likely cause your calendar to be displayed incorrectly.</strong>', AI1EC_PLUGIN_NAME) . ' ' . __('We recommend you back up the affected CSS/LESS files and remove them from <code>%s</code>. Try using your calendar and if changes are needed, place your custom CSS rules in <code>%scss%soverride.css</code> (or custom LESS rules in <code>%sless%soverride.less</code>).', AI1EC_PLUGIN_NAME), $theme, AI1EC_DEFAULT_THEME_NAME, AI1EC_DEFAULT_THEME_NAME, $theme, $slash, $slash, $slash, $slash); } // Display final report. $message = Ai1ec_Helper_Factory::create_admin_message_instance('<p>' . __("You are using a calendar theme that should be updated to the new conventions:", AI1EC_PLUGIN_NAME) . '</p><ol><li>' . implode('</li><li>', $errors) . '</li></ol><p>' . sprintf(__('<strong>Note:</strong> After modifying any of your theme’s CSS or LESS files, you <em>must</em> click <strong>Events</strong> > <strong>Theme Options</strong> > <strong>Save Options</strong> to refresh the compiled CSS used in the front-end.', AI1EC_PLUGIN_NAME) . '</p><p>' . __('You can learn more from our <a href="%s" target="_blank">Help Desk article</a>.', AI1EC_PLUGIN_NAME), 'http://help.time.ly/customer/portal/articles/803082') . '</p>', __("All-in-One Event Calendar Warning: Calendar theme is in legacy format", AI1EC_PLUGIN_NAME)); if (true === $display_now) { $message->render(); } else { $aie1c_admin_notices_helper = Ai1ec_Admin_Notices_Helper::get_instance(); $aie1c_admin_notices_helper->add_renderable_children($message); } } }
/** * (non-PHPdoc) * @see Ai1ec_Connector_Plugin::render_tab_content() */ public function render_tab_content() { // Render the opening div $this->render_opening_div_of_tab(); // Render the body of the tab global $ai1ec_view_helper, $ai1ec_settings_helper, $ai1ec_settings; $select2_cats = Ai1ec_View_Factory::create_select2_multiselect(array('name' => 'ai1ec_feed_category[]', 'id' => 'ai1ec_feed_category', 'use_id' => true, 'type' => 'category', 'placeholder' => __('Categories (optional)', AI1EC_PLUGIN_NAME)), get_terms('events_categories', array('hide_empty' => false))); $select2_tags = Ai1ec_View_Factory::create_select2_tags(array('id' => 'ai1ec_feed_tags')); $modal = Ai1ec_Helper_Factory::create_bootstrap_modal_instance(esc_html__("Do you want to keep the events imported from the calendar or remove them?", AI1EC_PLUGIN_NAME)); $modal->set_header_text(esc_html__("Removing ICS Feed", AI1EC_PLUGIN_NAME)); $modal->set_keep_button_text(esc_html__("Keep Events", AI1EC_PLUGIN_NAME)); $modal->set_delete_button_text(esc_html__("Remove Events", AI1EC_PLUGIN_NAME)); $modal->set_id('ai1ec-ics-modal'); $args = array('cron_freq' => $ai1ec_settings_helper->get_cron_freq_dropdown($ai1ec_settings->cron_freq), 'event_categories' => $select2_cats, 'event_tags' => $select2_tags, 'feed_rows' => $ai1ec_settings_helper->get_feed_rows(), 'modal' => $modal); $ai1ec_view_helper->display_admin('plugins/ics/display_feeds.php', $args); $this->render_closing_div_of_tab(); }
/** * Creates the HTML to display on the "Add new event" page so that the user can choose to export the event to Facebook. * * @return string an empty string or the html to show */ public function render_export_box() { global $post; // We only want this for events. if ($post->post_type !== AI1EC_POST_TYPE) { return; } try { $event = new Ai1ec_Event($post->ID); } catch (Ai1ec_Event_Not_Found $e) { // Post exists, but event data hasn't been saved yet. Create new event // object. $event = NULL; } // If we have an event end the event was imported from facebook, return, we can't export it. if ($event !== NULL && $event->facebook_status === Ai1ecFacebookConnectorPlugin::FB_IMPORTED_EVENT) { return; } $facebook = $this->facebook_instance_factory(); // Let's check if we have a user in session if ($this->get_current_facebook_user_from_cache() === NULL) { // No user in session, let's see if we have a token and the user can login. $current_user = Ai1ec_Facebook_Factory::get_facebook_user_instance($facebook); $logged_in = $current_user->do_login(); // If the user couldn't login, do not print anything but return an hidden inpsave_current_facebook_user_in_sessionut, in this way the // plugin save post handler simply returns. if ($logged_in === FALSE) { $hidden_input_name = self::FB_HIDDEN_INPUT_NO_ACTIVE_TOKEN; echo "<input type='hidden' name='{$hidden_input_name}' value='1' />"; return; } // Save it in session. $this->save_facebook_user_in_cache($current_user); } $checked = ''; if ($event !== NULL && $event->facebook_status === Ai1ecFacebookConnectorPlugin::FB_EXPORTED_EVENT) { $checked = 'checked'; } $link = ''; $modal_html = ''; $pages_html = ''; $tokens = array(); $refresh_button = ''; if (isset($event->facebook_eid) && (int) $event->facebook_eid !== 0) { $link_label = __("Linked Facebook event", AI1EC_PLUGIN_NAME); $link = "<div id='ai1ec-facebook-linked-event'><a href='https://www.facebook.com/events/{$event->facebook_eid}'>{$link_label}</a></div>"; // We include the modal only when the event has been exported to facebook $twitter_bootstrap_modal = Ai1ec_Helper_Factory::create_bootstrap_modal_instance(__("Would you like to delete the linked Facebook event or keep it? If you choose to keep it and later you export this event again, a new one will be created.", AI1EC_PLUGIN_NAME)); $twitter_bootstrap_modal->set_header_text(__("Unpublish Facebook event?", AI1EC_PLUGIN_NAME)); $twitter_bootstrap_modal->set_id("ai1ec-facebook-export-modal"); $twitter_bootstrap_modal->set_delete_button_text(__("Delete event", AI1EC_PLUGIN_NAME)); $twitter_bootstrap_modal->set_keep_button_text(__("Keep event", AI1EC_PLUGIN_NAME)); $modal_html = $twitter_bootstrap_modal->render_as_html(); } else { // check if page tokens are set $pages = $this->get_plugin_variable(self::PAGE_TOKENS); if (false === $pages) { $pages = $this->set_token_for_pages($facebook); } $current_user = $this->get_current_facebook_user_from_cache(); if (!empty($pages)) { $pages_html = Ai1ec_Facebook_Factory::create_export_to_pages_html($pages, $current_user); } $refresh_button = Ai1ec_Facebook_Factory::create_refresh_token_button(); } $label = __('Export event to Facebook?', AI1EC_PLUGIN_NAME); $name = self::FB_EXPORT_CHKBX_NAME; $html = <<<HTML <div id="ai1ec-facebook-publish" class="misc-pub-section"> \t<div id="ai1ec-facebook-small-logo"></div> \t<label for="{$name}"> \t\t{$label} \t</label> \t<input type="checkbox" {$checked} name="{$name}" id="{$name}" value="1" /> \t{$link} \t{$pages_html} \t{$refresh_button} </div> <div class="timely"> {$modal_html} </div> HTML; echo $html; }
/** * Create the modal for the event subscription * * @param $event Ai1ec_Event */ private function add_modal_for_email_subscription(Ai1ec_Event $event) { $current_user = wp_get_current_user(); $user_email = $current_user->user_email; unset($current_user); // Create containing div $div = Ai1ec_Helper_Factory::create_generic_html_tag('div'); $div->add_class('ai1ec_email_container form-horizontal'); $div->set_attribute('data-event_id', $event->post_id); $div->set_attribute('data-event_instance', $event->instance_id); // Add alert container to containing div $div_alerts = Ai1ec_Helper_Factory::create_generic_html_tag('div'); $div_alerts->add_class('alerts'); // Add paragraph to containing div $paragraph = Ai1ec_Helper_Factory::create_generic_html_tag('p'); $paragraph->set_text(__('Enter your email address below to receive a notification about the event 6 hours before it starts.', AI1EC_PLUGIN_NAME)); $div->add_renderable_children($paragraph); // Add div.control-group to containing div $control_group = Ai1ec_Helper_Factory::create_generic_html_tag('div'); $control_group->add_class('control-group'); $div->add_renderable_children($control_group); // Add label to div.control-group $label = Ai1ec_Helper_Factory::create_generic_html_tag('label'); $label->add_class('control-label'); $label->set_attribute('for', 'ai1ec_email_subscribe'); $label->set_text(__('Email:', AI1EC_PLUGIN_NAME)); $control_group->add_renderable_children($label); // Add div.controls to div.control-group $controls = Ai1ec_Helper_Factory::create_generic_html_tag('div'); $controls->add_class('controls'); $control_group->add_renderable_children($controls); // Add input to div.controls $input = Ai1ec_Helper_Factory::create_input_instance(); $input->set_id('ai1ec_email_subscribe'); $input->set_name('ai1ec_email_subscribe'); if (!empty($user_email)) { $input->set_value($user_email); } $input->set_attribute('placeholder', __('Email', AI1EC_PLUGIN_NAME)); $controls->add_renderable_children($input); // Create modal and add our enclosing div to it $bootstrap_modal = Ai1ec_Helper_Factory::create_bootstrap_modal_instance($div_alerts->render_as_html() . $div->render_as_html()); $bootstrap_modal->set_header_text(__('Get notified about this event', AI1EC_PLUGIN_NAME)); $bootstrap_modal->set_id('ai1ec_subscribe_email_modal'); $bootstrap_modal->add_class('fade'); $bootstrap_modal->set_keep_button_text('<i class="icon-ok"></i> ' . __('Subscribe', AI1EC_PLUGIN_NAME)); $bootstrap_modal->set_delete_button_text('<i class="icon-remove"></i> ' . __('Close', AI1EC_PLUGIN_NAME)); $ai1ec_deferred_helper = Ai1ec_Deferred_Rendering_Helper::get_instance(); $ai1ec_deferred_helper->add_renderable_children($bootstrap_modal); }
/** * apply_delta method * * Attempt to parse and apply given database tables definition, as a delta. * Some validation is made prior to calling DB, and fields/indexes are also * checked for consistency after sending queries to DB. * * NOTICE: only "CREATE TABLE" statements are handled. Others will, likely, * be ignored, if passed through this method. * * @param string|array $query Single or multiple queries to perform on DB * * @return bool Success * * @throws Ai1ec_Database_Error In case of any error */ public function apply_delta($query) { if (!function_exists('dbDelta')) { require_once ABSPATH . 'wp-admin' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'upgrade.php'; } $success = false; try { $this->_schema_delta = array(); $queries = $this->_prepare_delta($query); $result = dbDelta($queries); $success = $this->_check_delta(); } catch (Ai1ec_Database_Error $failure) { $message = Ai1ec_Helper_Factory::create_admin_message_instance('<p>' . __('Database update has failed. Please make sure, that database user, defined in <em>wp-config.php</em> has permissions, to make changes (<strong>ALTER TABLE</strong>) to the database.', AI1EC_PLUGIN_NAME) . '</p>', __('Plug-in disabled due to unrecoverable database update error', AI1EC_PLUGIN_NAME)); $this->get_notices_helper()->add_renderable_children($message); if (!function_exists('deactivate_plugins')) { require ABSPATH . 'wp-admin/includes/plugin.php'; } deactivate_plugins(AI1EC_PLUGIN_BASENAME, true); } return $success; }
/** * Renders the Facebook Graph Object that user has subscribed to. * * @param array $types the Type of Facebook Graph Objects to render * * @param $current_id The id of the currently logged on user which must be excluded from subscribers and multiselects * * @return string the HTML */ private function render_subscribers(array $types, $current_id) { $subscribers = $this->render_all_elements($types, FALSE, $current_id); $html = ''; foreach ($types as $type) { $text = Ai1ec_Facebook_Graph_Object_Collection::get_type_printable_text($type); $html .= <<<HTML <div class="ai1ec-facebook-items" data-type="{$type}"> \t<h2 class="ai1ec-facebook-header">{$text}</h2> \t{$subscribers[$type]} </div> HTML; } $keep_events = __("Keep Events", AI1EC_PLUGIN_NAME); $remove_events = __("Remove Events", AI1EC_PLUGIN_NAME); $body = __("Would you like to remove these events from your calendar, or preserve them?", AI1EC_PLUGIN_NAME); $removing = __("Removing the following subscription: ", AI1EC_PLUGIN_NAME); $header_text = $removing . '<span id="ai1ec-facebook-user-modal"></span>'; // Attach the modal for when you unsubscribe. $twitter_bootstrap_modal = Ai1ec_Helper_Factory::create_bootstrap_modal_instance($body); $twitter_bootstrap_modal->set_id('ai1ec-facebook-modal'); $twitter_bootstrap_modal->set_delete_button_text($remove_events); $twitter_bootstrap_modal->set_keep_button_text($keep_events); $twitter_bootstrap_modal->set_header_text($header_text); $html .= $twitter_bootstrap_modal->render_as_html(); return $html; }
/** * @return Ai1ec_Generic_Html_Tag */ public static function create_save_filtered_view_buttongroup(array $view_args, $shortcode) { $btn_group = Ai1ec_Helper_Factory::create_generic_html_tag('div'); $btn_group->add_class('btn-group'); $btn = Ai1ec_Helper_Factory::create_bootstrap_button_instance(); $btn->add_class('btn-mini ai1ec-tooltip-trigger'); $btn->set_id('save_filtered_views'); $icon = Ai1ec_Helper_Factory::create_generic_html_tag('icon'); $icon->add_class('icon-pushpin'); $btn->add_renderable_children($icon); $ai1ec_router = Ai1ec_Router::instance(); $cookie_dto = $ai1ec_router->get_cookie_set_dto(); $cookie_set = $cookie_dto->get_is_a_cookie_set_for_this_page(); // if there are no filter set, but the cookie is set i need to show the button so that the cookie can be removed if (false === Ai1ec_Router::is_at_least_one_filter_set_in_request($view_args) && !$cookie_set) { $btn->add_class('hide'); } $cookie = false; if (true === $cookie_set) { $cookie = 'true' === $shortcode ? $cookie_dto->get_shortcode_cookie() : $cookie_dto->get_calendar_cookie(); } // If we have a cookie and the filters are in the same state of the cookie, show the remove version // Saving the same state again would not make sense // if we have a cookie and no filters are set, show the remove button, the user can't save the // standard calendar view if ($cookie_set && (self::check_if_saved_cookie_and_requested_page_match($view_args, $cookie) || false === Ai1ec_Router::is_at_least_one_filter_set_in_request($view_args))) { $btn->add_class('active'); $text = __("Remove default filter", AI1EC_PLUGIN_NAME); } else { $text = __("Save this filter as default", AI1EC_PLUGIN_NAME); } // Add a span to hold text $btn->set_attribute('title', $text); $btn_group->add_renderable_children($btn); return $btn_group; }
/** * Create the page * * @return Ai1ec_Less_Variables_Editing_Page */ public static function create_less_variables_editing_page_instance() { $less_variable_page = new Ai1ec_Less_Variables_Editing_Page(Ai1ec_Adapters_Factory::create_menu_adapter_instance(), Ai1ec_Helper_Factory::create_view_helper_instance(), Ai1ec_Adapters_Factory::create_template_adapter_instance()); return $less_variable_page; }
/** * Update the less variables on the DB and recompile the CSS * * @param array $variables * @param boolean $resetting are we resetting or updating variables? */ private function update_variables_and_compile_css(array $variables, $resetting) { $no_parse_errors = $this->invalidate_cache($variables, true); if ($no_parse_errors) { $this->db_adapter->write_data_to_config(Ai1ec_Lessphp_Controller::DB_KEY_FOR_LESS_VARIABLES, $variables); $message = Ai1ec_Helper_Factory::create_admin_message_instance(sprintf('<p>' . __("Theme options were updated successfully. <a href='%s'>Visit site</a>", AI1EC_PLUGIN_NAME) . '</p>', get_site_url())); if (true === $resetting) { $message = Ai1ec_Helper_Factory::create_admin_message_instance(sprintf('<p>' . __("Theme options were successfully reset to their default values. <a href='%s'>Visit site</a>", AI1EC_PLUGIN_NAME) . '</p>', get_site_url())); } $message->set_message_type('updated'); $this->admin_notices_helper->add_renderable_children($message); } }
/** * Create a duplicate from a posts' instance */ function duplicate_post_create_duplicate($post, $status = '') { $new_post_author = $this->duplicate_post_get_current_user(); $new_post_status = $status; if (empty($new_post_status)) { $new_post_status = $post->post_status; } $new_post = array('menu_order' => $post->menu_order, 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status, 'pinged' => $post->pinged, 'post_author' => $new_post_author->ID, 'post_content' => $post->post_content, 'post_date' => $post->post_date, 'post_date_gmt' => get_gmt_from_date($post->post_date), 'post_excerpt' => $post->post_excerpt, 'post_parent' => $post->post_parent, 'post_password' => $post->post_password, 'post_status' => $new_post_status, 'post_title' => $post->post_title, 'post_type' => $post->post_type, 'to_ping' => $post->to_ping); $new_post_id = wp_insert_post($new_post); $edit_event_url = esc_attr(admin_url("post.php?post={$new_post_id}&action=edit")); $message = Ai1ec_Helper_Factory::create_admin_message_instance(sprintf(__('<p>The event <strong>%s</strong> was cloned succesfully. <a href="%s">Edit cloned event</a></p>', AI1EC_PLUGIN_NAME), $post->post_title, $edit_event_url)); $message->set_message_type('updated'); $this->admin_notice_helper->add_renderable_children($message); // If you have written a plugin which uses non-WP database tables to save // information about a post you can hook this action to dupe that data. if ($post->post_type == 'page' || function_exists('is_post_type_hierarchical') && is_post_type_hierarchical($post->post_type)) { do_action('dp_duplicate_page', $new_post_id, $post); } else { do_action('dp_duplicate_post', $new_post_id, $post); } delete_post_meta($new_post_id, '_dp_original'); add_post_meta($new_post_id, '_dp_original', $post->ID); // If the copy gets immediately published, we have to set a proper slug. if ($new_post_status == 'publish' || $new_post_status == 'future') { $post_name = wp_unique_post_slug($post->post_name, $new_post_id, $new_post_status, $post->post_type, $post->post_parent); $new_post = array(); $new_post['ID'] = $new_post_id; $new_post['post_name'] = $post_name; // Update the post into the database wp_update_post($new_post); } return $new_post_id; }
/** * Handle request - perform variables initialization and inner routing * * @return bool OAuth success status */ public function handle_request() { $result = false; $message = NULL; try { $this->_provider = $this->get_provider(); $result = $this->authorize(); } catch (Ai1ec_Oauth_Exception $exception) { // @RELEASE $this->_log->error( 'OAuth failure: ' . $exception->getMessage() ); $result = false; $message = $exception->getMessage(); } $renderable = NULL; if ($result) { $renderable = Ai1ec_Helper_Factory::create_admin_message_instance(sprintf(__('You have successfully linked your account with <strong>%s</strong>.', AI1EC_PLUGIN_NAME), $this->_provider->get_name()), __('External Service linked', AI1EC_PLUGIN_NAME)); $renderable->set_message_type('updated'); } else { $renderable = Ai1ec_Helper_Factory::create_admin_message_instance(sprintf(__('There was a failure linking your account with <strong>%s</strong>: %s.', AI1EC_PLUGIN_NAME), $this->_provider->get_name(), $message), __('External Service linking error', AI1EC_PLUGIN_NAME)); $renderable->set_message_type('error'); } Ai1ec_Deferred_Rendering_Helper::get_instance()->add_renderable_children($renderable); return ai1ec_redirect(admin_url(AI1EC_SETTINGS_BASE_URL)); }