static function pdfMain(PluginPdfSimplePDF $pdf, KnowbaseItem $item) { global $DB; $ID = $item->getField('id'); if (!Session::haveRight('knowbase', 'r') || !Session::haveRight('faq', 'r')) { return false; } $knowbaseitemcategories_id = $item->getField('knowbaseitemcategories_id'); $fullcategoryname = Html::clean(getTreeValueCompleteName("glpi_knowbaseitemcategories", $knowbaseitemcategories_id)); $question = Html::clean(Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($item->getField('name'), ENT_QUOTES, "UTF-8"))); $answer = Html::clean(Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($item->getField('answer'), ENT_QUOTES, "UTF-8"))); $pdf->setColumnsSize(100); if (Toolbox::strlen($fullcategoryname) > 0) { $pdf->displayTitle('<b>' . __('Category name') . '</b>'); $pdf->displayLine($fullcategoryname); } if (Toolbox::strlen($question) > 0) { $pdf->displayTitle('<b>' . __('Subject') . '</b>'); $pdf->displayText('', $question, 5); } else { $pdf->displayTitle('<b>' . __('No question found', 'pdf') . '</b>'); } if (Toolbox::strlen($answer) > 0) { $pdf->displayTitle('<b>' . __('Content') . '</b>'); $pdf->displayText('', $answer, 5); } else { $pdf->displayTitle('<b>' . __('No answer found') . '</b>'); } $pdf->setColumnsSize(50, 15, 15, 10, 10); $pdf->displayTitle(__('Writer'), __('Creation date'), __('Last update'), __('FAQ'), _n('View', 'Views', 2)); $pdf->displayLine(getUserName($item->fields["users_id"]), Html::convDateTime($item->fields["date"]), Html::convDateTime($item->fields["date_mod"]), Dropdown::getYesNo($item->fields["is_faq"]), $item->fields["view"]); $pdf->displaySpace(); }
/** * Recheck all comments in the Pending queue. * * ## EXAMPLES * * wp akismet recheck_queue * * @alias recheck-queue */ public function recheck_queue() { $batch_size = 100; $start = 0; $total_counts = array(); do { $result_counts = Akismet_Admin::recheck_queue_portion($start, $batch_size); if ($result_counts['processed'] > 0) { foreach ($result_counts as $key => $count) { if (!isset($total_counts[$key])) { $total_counts[$key] = $count; } else { $total_counts[$key] += $count; } } $start += $batch_size; $start -= $result_counts['spam']; // These comments will have been removed from the queue. } } while ($result_counts['processed'] > 0); WP_CLI::line(sprintf(_n("Processed %d comment.", "Processed %d comments.", $total_counts['processed'], 'akismet'), number_format($total_counts['processed']))); WP_CLI::line(sprintf(_n("%d comment moved to Spam.", "%d comments moved to Spam.", $total_counts['spam'], 'akismet'), number_format($total_counts['spam']))); if ($total_counts['error']) { WP_CLI::line(sprintf(_n("%d comment could not be checked.", "%d comments could not be checked.", $total_counts['error'], 'akismet'), number_format($total_counts['error']))); } }
function woo_warp_side_cart() { ?> <link rel="stylesheet" type="text/css" href="<?php echo '' . plugins_url('css/style.css', __FILE__) . ''; ?> "> <div class="side-cart uk-panel uk-panel-box uk-panel-box-secondary"> <span class="ww-cart-icon side-cart uk-panel uk-panel-box uk-panel-box-primary"> <span class="uk-icon-shopping-cart"></span> </span> <p> <?php echo sprintf(_n('%d item', '%d items', WC()->cart->cart_contents_count), WC()->cart->cart_contents_count); ?> <br /> <?php echo WC()->cart->get_cart_total(); ?> </p> <a class="uk-button uk-button-mini uk-width-1-1 uk-button-primary" href="<?php echo WC()->cart->get_cart_url(); ?> " title="<?php _e('View Cart'); ?> ">View Cart</a> </div> <?php }
static function pdfForSoftware(PluginPdfSimplePDF $pdf, Software $software, $infocom = false) { global $DB; $sID = $software->getField('id'); $license = new SoftwareLicense(); $query = "SELECT `id`\n FROM `glpi_softwarelicenses`\n WHERE `softwares_id` = '" . $sID . "' " . getEntitiesRestrictRequest('AND', 'glpi_softwarelicenses', '', '', true) . "\n ORDER BY `name`"; $pdf->setColumnsSize(100); $pdf->displayTitle('<b>' . _n('License', 'Licenses', 2) . '</b>'); if ($result = $DB->query($query)) { if ($DB->numrows($result)) { for ($tot = 0; $data = $DB->fetch_assoc($result);) { if ($license->getFromDB($data['id'])) { self::pdfMain($pdf, $license, false); if ($infocom) { PluginPdfInfocom::pdfForItem($pdf, $license); } } } } else { $pdf->displayLine(__('No item found')); } } else { $pdf->displayLine(__('No item found')); } $pdf->displaySpace(); }
/** * Set up the view with data and do things that are specific for this view * * @since 1.0.0 * * @param string $action Action for this view * @param array $data Data for this view */ public function setup($action, $data) { parent::setup($action, $data); add_thickbox(); $this->admin_page->enqueue_script('list', array('jquery'), array('list' => array('shortcode_popup' => __('To embed this table into a post or page, use this Shortcode:', 'tablepress'), 'donation-message-already-donated' => __('Thank you very much! Your donation is highly appreciated. You just contributed to the further development of TablePress!', 'tablepress'), 'donation-message-maybe-later' => sprintf(__('No problem! I still hope you enjoy the benefits that TablePress adds to your site. If you should change your mind, you\'ll always find the “Donate” button on the <a href="%s">TablePress website</a>.', 'tablepress'), 'http://tablepress.org/')))); if ($data['messages']['first_visit']) { $this->add_header_message('<strong><em>' . __('Welcome!', 'tablepress') . '</em></strong><br />' . __('Thank you for using TablePress for the first time!', 'tablepress') . ' ' . sprintf(__('If you encounter any questions or problems, please visit the <a href="%1$s">FAQ</a>, the <a href="%2$s">documentation</a>, and the <a href="%3$s">Support</a> section on the <a href="%4$s">plugin website</a>.', 'tablepress'), 'http://tablepress.org/faq/', 'http://tablepress.org/documentation/', 'http://tablepress.org/support/', 'http://tablepress.org/') . '<br /><br />' . $this->ajax_link(array('action' => 'hide_message', 'item' => 'first_visit', 'return' => 'list'), __('Hide this message', 'tablepress'))); } if ($data['messages']['wp_table_reloaded_warning']) { $this->add_header_message('<strong><em>' . __('Attention!', 'tablepress') . '</em></strong><br />' . __('You have activated the plugin WP-Table Reloaded, which can not be used together with TablePress.', 'tablepress') . '<br />' . __('It is strongly recommended that you switch from WP-Table Reloaded to TablePress, which not only fixes many problems, but also has more and better features than WP-Table Reloaded.', 'tablepress') . '<br />' . sprintf(__('Please follow the <a href="%s">migration guide</a> to move your tables and then deactivate WP-Table Reloaded!', 'tablepress'), 'http://tablepress.org/migration-from-wp-table-reloaded/') . '<br />' . '<a href="' . TablePress::url(array('action' => 'import')) . '" class="button button-primary button-large" title="' . __('Import your tables from WP-Table Reloaded', 'tablepress') . '" style="color:#ffffff;margin-top:5px;">' . __('Import your tables from WP-Table Reloaded', 'tablepress') . '</a>', 'error'); } if ($data['messages']['donation_message']) { $this->add_header_message('<img alt="' . __('Tobias Bäthge, developer of TablePress', 'tablepress') . '" src="https://secure.gravatar.com/avatar/50f1cff2e27a1f522b18ce229c057bc5?s=94" height="94" width="94" style="float:left;margin-right:10px;" />' . __('Hi, my name is Tobias, I\'m the developer of the TablePress plugin.', 'tablepress') . '<br /><br />' . __('Thanks for using it! You\'ve installed TablePress over a month ago.', 'tablepress') . ' ' . sprintf(_n('If everything works and you are satisfied with the results of managing your %s table, isn\'t that worth a coffee or two?', 'If everything works and you are satisfied with the results of managing your %s tables, isn\'t that worth a coffee or two?', $data['table_count'], 'tablepress'), $data['table_count']) . '<br/>' . sprintf(__('<a href="%s">Donations</a> help me to continue user support and development of this <em>free</em> software — things for which I spend countless hours of my free time! Thank you very much!', 'tablepress'), 'http://tablepress.org/donate/') . '<br/><br />' . __('Sincerly, Tobias', 'tablepress') . '<br /><br />' . sprintf('<a href="%s" target="_blank"><strong>%s</strong></a>', 'http://tablepress.org/donate/', __('Sure, I\'ll buy you a coffee and support TablePress!', 'tablepress')) . ' · ' . $this->ajax_link(array('action' => 'hide_message', 'item' => 'donation_nag', 'return' => 'list', 'target' => 'already-donated'), __('I already donated.', 'tablepress')) . ' · ' . $this->ajax_link(array('action' => 'hide_message', 'item' => 'donation_nag', 'return' => 'list', 'target' => 'maybe-later'), __('No, thanks. Don\'t ask again.', 'tablepress'))); } if ($data['messages']['show_plugin_update']) { $message = '<strong><em>' . sprintf(__('Thank you for updating to TablePress %s!', 'tablepress'), TablePress::version) . '</em></strong><br />'; if (!empty($data['messages']['plugin_update_message'])) { $message .= $data['messages']['plugin_update_message'] . '<br />'; } $message .= sprintf(__('Please read the <a href="%s">release announcement</a> for more information.', 'tablepress'), 'http://tablepress.org/news/') . ' ' . sprintf(__('If you like the new features and enhancements, <a href="%s">giving a donation</a> towards the further support and development of TablePress is recommended. Thank you!', 'tablepress'), 'http://tablepress.org/donate/') . '<br /><br />'; $message .= $this->ajax_link(array('action' => 'hide_message', 'item' => 'plugin_update', 'return' => 'list'), __('Hide this message', 'tablepress')); $this->add_header_message($message); } $this->process_action_messages(array('success_delete' => _n('The table was deleted successfully.', 'The tables were deleted successfully.', 1, 'tablepress'), 'success_delete_plural' => _n('The table was deleted successfully.', 'The tables were deleted successfully.', 2, 'tablepress'), 'error_delete' => __('Error: The table could not be deleted.', 'tablepress'), 'error_save' => __('Error: The table could not be saved.', 'tablepress'), 'success_copy' => _n('The table was copied successfully.', 'The tables were copied successfully.', 1, 'tablepress'), 'success_copy_plural' => _n('The table was copied successfully.', 'The tables were copied successfully.', 2, 'tablepress'), 'error_copy' => __('Error: The table could not be copied.', 'tablepress'), 'error_no_table' => __('Error: You did not specify a valid table ID.', 'tablepress'), 'error_load_table' => __('Error: This table could not be loaded!', 'tablepress'), 'error_bulk_action_invalid' => __('Error: This bulk action is invalid!', 'tablepress'), 'error_no_selection' => __('Error: You did not select any tables!', 'tablepress'), 'error_delete_not_all_tables' => __('Notice: Not all selected tables could be deleted!', 'tablepress'), 'error_copy_not_all_tables' => __('Notice: Not all selected tables could be copied!', 'tablepress'), 'success_import' => __('The tables were imported successfully.', 'tablepress'), 'success_import_wp_table_reloaded' => __('The tables were imported successfully from WP-Table Reloaded.', 'tablepress'))); $this->add_text_box('head', array($this, 'textbox_head'), 'normal'); $this->add_text_box('tables-list', array($this, 'textbox_tables_list'), 'normal'); add_screen_option('per_page', array('label' => __('Tables', 'tablepress'), 'default' => 20)); // Admin_Controller contains function to allow changes to this in the Screen Options to be saved $this->wp_list_table = new TablePress_All_Tables_List_Table(); $this->wp_list_table->set_items($this->data['tables']); $this->wp_list_table->prepare_items(); // cleanup Request URI string, which WP_List_Table uses to generate the sort URLs $_SERVER['REQUEST_URI'] = remove_query_arg(array('message', 'table_id'), $_SERVER['REQUEST_URI']); }
public static function _n($single, $plural, $number, $domain = null) { if (!$domain) { $domain = Core::ID; } return \_n($single, $plural, $number, $domain); }
/** * The constuctor * * @since 2.4.0 */ public function __construct() { // Allowed cover image types & upload size $allowed_types = bp_attachments_get_allowed_types('cover_image'); $max_upload_file_size = bp_attachments_get_max_upload_file_size('cover_image'); parent::__construct(array('action' => 'bp_cover_image_upload', 'file_input' => 'file', 'original_max_filesize' => $max_upload_file_size, 'base_dir' => bp_attachments_uploads_dir_get('dir'), 'required_wp_files' => array('file', 'image'), 'upload_error_strings' => array(11 => sprintf(__('That image is too big. Please upload one smaller than %s', 'buddypress'), size_format($max_upload_file_size)), 12 => sprintf(_n('Please upload only this file type: %s.', 'Please upload only these file types: %s.', count($allowed_types), 'buddypress'), self::get_cover_image_types($allowed_types))))); }
function showForm($target, $ID) { $this->getFromDB($ID); $delay_expired = $this->fields["delay_expired"]; $delay_whichexpire = $this->fields["delay_whichexpire"]; echo "<div align='center'>"; echo "<form method='post' action=\"{$target}\">"; echo "<table class='tab_cadre_fixe' cellpadding='5'><tr><th>"; echo __('Time of checking of validity of domains', 'domains') . "</th></tr>"; echo "<tr class='tab_bg_1'><td><div align='center'>"; $delay_stamp_first = mktime(0, 0, 0, date("m"), date("d") - $delay_expired, date("y")); $delay_stamp_next = mktime(0, 0, 0, date("m"), date("d") + $delay_whichexpire, date("y")); $date_first = date("Y-m-d", $delay_stamp_first); $date_next = date("Y-m-d", $delay_stamp_next); echo "<tr class='tab_bg_1'><td><div align='left'>"; _e('Domains expired since more', 'domains'); echo " <input type='text' size='5' name='delay_expired' value=\"{$delay_expired}\">"; echo " " . _n('Day', 'Days', 2); echo " ( >" . Html::convdate($date_first) . ")<br>"; _e('Domains expiring in less than', 'domains'); echo " <input type='text' size='5' name='delay_whichexpire' value=\"{$delay_whichexpire}\">"; echo " " . _n('Day', 'Days', 2); echo " ( <" . Html::convdate($date_next) . ")"; echo "</td>"; echo "</tr>"; echo "<tr><th>"; echo "<input type='hidden' name='id' value='" . $ID . "'>"; echo "<div align='center'>"; echo "<input type='submit' name='update' value=\"" . __s('Post') . "\" class='submit' >"; echo "</div></th></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; }
function customize_registering($wp_customize) { global $xili_language; // in_nav_menu $locations = get_registered_nav_menus(); $menus = wp_get_nav_menus(); $menu_locations = get_nav_menu_locations(); $num_locations = count(array_keys($locations)); if ($num_locations >= 1 && count($menu_locations) >= 1) { $wp_customize->add_section('xili_options_section', array('title' => __('Multilingual Options ©xili', 'xili-language'), 'priority' => 300, 'description' => sprintf(_n('Your theme supports %s menu. Customize style.', 'Your theme supports %s menus. Customize style.', $num_locations, 'xili-language'), number_format_i18n($num_locations)) . "\n\n" . __('You can edit your menu content on the Menus screen in the Appearance section.'))); $location_slugs = array_keys($locations); if (0 == $xili_language->has_languages_list_menu($location_slugs[0])) { // only test one menu during transition $wp_customize->add_setting('xili_language_settings[in_nav_menu]', array('default' => '', 'transport' => 'refresh', 'type' => 'option', 'capability' => $this->capability)); $wp_customize->add_control('in_nav_menu', array('settings' => 'xili_language_settings[in_nav_menu]', 'label' => __('Append the languages', 'xili-language'), 'section' => 'xili_options_section', 'type' => 'radio', 'choices' => array('disable' => __('No languages menu-items', 'xili-language'), 'enable' => __('Show languages menu-items', 'xili-language')))); $wp_customize->add_setting('xili_language_settings[nav_menu_separator]', array('default' => '|', 'transport' => 'refresh', 'type' => 'option', 'capability' => $this->capability)); $wp_customize->add_control('nav_menu_separator', array('settings' => 'xili_language_settings[nav_menu_separator]', 'label' => __('Separator before language list (Character or Entity Number or Entity Name)', 'xili-language'), 'section' => 'xili_options_section', 'type' => 'text')); } if (!current_theme_supports('custom_xili_flag')) { $wp_customize->add_setting($this->settings_name . '[no_flags]', array('default' => '', 'transport' => 'refresh', 'type' => 'option', 'capability' => $this->capability)); $wp_customize->add_control('no_flags', array('settings' => $this->settings_name . '[no_flags]', 'label' => __('Hide the flags', 'xili-language'), 'section' => 'xili_options_section', 'type' => 'checkbox')); } } else { $wp_customize->add_section('xili_options_section', array('title' => __('Multilingual Options ©xili', 'xili-language'), 'priority' => 300, 'description' => __('None nav menus location seems active', 'xili-language'))); } $wp_customize->add_setting($this->settings_name . '[linked_posts]', array('default' => '', 'transport' => 'refresh', 'type' => 'option', 'capability' => $this->capability)); $wp_customize->add_control('linked_posts', array('settings' => $this->settings_name . '[linked_posts]', 'label' => __('Show linked posts', 'xili-language'), 'section' => 'xili_options_section', 'type' => 'checkbox')); }
public function widget($args, $instance) { $title = apply_filters('widget_title', @$instance['title']); echo $args['before_widget']; if (!empty($title)) { echo $args['before_title'] . $title . $args['after_title']; } $ans_count = ap_question_get_the_answer_count(); $last_active = ap_question_get_the_active_ago(); $total_subs = ap_question_get_the_subscriber_count(); $view_count = ap_question_get_the_view_count(); echo '<div class="ap-widget-inner">'; if (is_question()) { echo '<ul class="ap-stats-widget">'; echo '<li><span class="stat-label apicon-pulse">' . __('Active', 'ap') . '</span><span class="stat-value"><time class="published updated" itemprop="dateModified" datetime="' . mysql2date('c', $last_active) . '">' . ap_human_time(mysql2date('U', $last_active)) . '</time></span></li>'; echo '<li><span class="stat-label apicon-eye">' . __('Views', 'ap') . '</span><span class="stat-value">' . sprintf(_n('One time', '%d times', $view_count, 'ap'), $view_count) . '</span></li>'; echo '<li><span class="stat-label apicon-answer">' . __('Answers', 'ap') . '</span><span class="stat-value">' . sprintf(_n('%2$s1%3$s answer', '%2$s%1$d%3$s answers', $ans_count, 'ap'), $ans_count, '<span data-view="answer_count">', '</span>') . '</span></li>'; echo '<li><span class="stat-label apicon-mail">' . __('Followers', 'ap') . '</span><span class="stat-value">' . sprintf(_n('1 follower', '%d followers', $total_subs, 'ap'), $total_subs) . '</span></li>'; echo '</ul>'; } else { _e('This widget can only be used in single question page', 'ap'); } echo '</div>'; echo $args['after_widget']; }
function getSearchOptions() { $tab = array(); $tab['common'] = _n('Characteristic', 'Characteristics', 2); $tab[1]['table'] = $this->getTable(); $tab[1]['field'] = 'id'; $tab[1]['name'] = __('ID'); $tab[1]['massiveaction'] = false; $tab[2]['table'] = "glpi_plugin_monitoring_services"; $tab[2]['field'] = 'name'; $tab[2]['linkfield'] = 'plugin_monitoring_services_id'; $tab[2]['name'] = __('Ressource', 'monitoring'); $tab[2]['datatype'] = 'itemlink'; $tab[2]['itemlink_type'] = 'PluginMonitoringService'; $tab[3]['table'] = $this->getTable(); $tab[3]['field'] = 'begin_date'; $tab[3]['name'] = __('Start', 'monitoring'); $tab[3]['datatype'] = 'datetime'; $tab[3]['massiveaction'] = false; $tab[4]['table'] = $this->getTable(); $tab[4]['field'] = 'end_date'; $tab[4]['name'] = __('End', 'monitoring'); $tab[4]['datatype'] = 'datetime'; $tab[4]['massiveaction'] = false; $tab[5]['table'] = $this->getTable(); $tab[5]['field'] = 'duration'; $tab[5]['name'] = __('Duration', 'monitoring'); $tab[5]['datatype'] = 'timestamp'; $tab[5]['withseconds'] = true; $tab[5]['massiveaction'] = false; return $tab; }
function p2_get_discussion_links() { $comments = get_comments(array('post_id' => get_the_ID())); $unique_commentors = array(); foreach ($comments as $comment) { if ('1' == $comment->comment_approved) { $unique_commentors[$comment->comment_author_email] = get_avatar($comment, 16) . ' ' . get_comment_author_link($comment->comment_ID); } } $unique_commentors = array_values($unique_commentors); $total_unique_commentors = count($unique_commentors); $content = ''; if (1 == $total_unique_commentors) { $content = sprintf(__('%1$s is discussing.', 'p2'), $unique_commentors[0]); } else { if (2 == $total_unique_commentors) { $content = sprintf(__('%1$s and %2$s are discussing.', 'p2'), $unique_commentors[0], $unique_commentors[1]); } else { if (3 == $total_unique_commentors) { $content = sprintf(__('%1$s, %2$s, and %3$s are discussing.', 'p2'), $unique_commentors[0], $unique_commentors[1], $unique_commentors[2]); } else { if (3 < $total_unique_commentors) { $others = $total_unique_commentors - 3; $content .= sprintf(_n('%1$s, %2$s, %3$s, and %4$d other are discussing.', '%1$s, %2$s, %3$s, and %4$d others are discussing.', $others, 'p2'), $unique_commentors[0], $unique_commentors[1], $unique_commentors[2], $others); } } } } return $content; }
/** * @since 1.0.0 * @return string */ protected function import_content() { $api_key = sanitize_text_field($_POST['mailchimp_api_key']); $list_id = sanitize_text_field($_POST[$this->import_list_name]); $signup_list_index = absint($_POST['signup_list_index']); $signup_lists = Prompt_Subscribing::get_signup_lists(); $import = new Prompt_Admin_MailChimp_Import($api_key, $list_id, $signup_lists[$signup_list_index]); $import->execute(); $content = html('h3', __('Here\'s how it went', 'Postmatic')); $content .= $import->get_error() ? $import->get_error()->get_error_message() : ''; $results_format = _n('Imported one subscriber.', 'Imported %1$s subscribers.', $import->get_imported_count(), 'Postmatic'); if ($import->get_already_subscribed_count() > 0) { $results_format .= ' ' . _n('The one valid user we found was already subscribed.', 'The %2$s valid users we found were already subscribed.', $import->get_already_subscribed_count(), 'Postmatic'); } $rejects = $import->get_rejected_subscribers(); $reject_content = ''; $reject_button = ''; if ($rejects) { $results_format .= '<br />' . _n('One user didn\'t qualify for importing.', 'There were %3$s users which didn\'t qualify for importing.', count($rejects)); $reject_content = html('div id="mailpoet-import-intro"', html('div', html('h4', __('Why weren\'t more of my users imported?', 'Postmatic')), html('p', __('We have a very strict policy regarding user imports: <em>we will never allow anyone to be subscribed to a blog running Postmatic without them having opted in</em> (such as subscriber lists bought and imported in bulk for spamming). Because of this we will not import any MailChimp subscribers unless the following two conditions are true:', 'Postmatic')), html('ol', html('li', __('The user has double opted-in to your MailChimp list', 'Postmatic')), html('li', __('The user exists on a list which is at least 14 days old', 'Postmatic'))), html('h5', __('Why so strict?', 'Postmatic')), html('p', __('Bulk importing unwilling users is easy in MailChimp. If we did not hold our import to a higher standard those unwilling users could be imported into Postmatic. And then they would spam your users. MailChimp is a one-way street. Postmatic is a conversation. That\'s a very important difference.', 'Postmatic')), html('h4', __('But we do have good news', 'Postmatic')), html('p', __('You can send an email to your remaining users. They will be invited to join your site by simply replying.', 'Postmatic')))); $rejected_addresses = array(); foreach ($rejects as $reject) { $name = trim($reject['email']); //$name = trim( $reject['firstname'] . ' ' . $reject['lastname'] ); $rejected_addresses[] = Prompt_Email_Batch::name_address($reject['email'], $name); } $reject_button = html('input', array('name' => $this->rejected_addresses_name, 'class' => 'button', 'data-addresses' => implode(",", $rejected_addresses), 'type' => 'submit', 'value' => __('Preview and send the invitations', 'Postmatic'))); } $content = html('p', $content, sprintf($results_format, $import->get_imported_count(), $import->get_already_subscribed_count(), count($rejects)), $reject_content, $reject_button); return $content; }
function ajax_response() { check_ajax_referer('ajax-custom-list-nonce', '_ajax_custom_list_nonce'); $this->prepare_items(); extract($this->_args); extract($this->_pagination_args, EXTR_SKIP); ob_start(); if (!empty($_REQUEST['no_placeholder'])) { $this->display_rows(); } else { $this->display_rows_or_placeholder(); } $rows = ob_get_clean(); ob_start(); $this->print_column_headers(); $headers = ob_get_clean(); ob_start(); $this->pagination('top'); $pagination_top = ob_get_clean(); ob_start(); $this->pagination('bottom'); $pagination_bottom = ob_get_clean(); $response = array('rows' => $rows); $response['pagination']['top'] = $pagination_top; $response['pagination']['bottom'] = $pagination_bottom; $response['column_headers'] = $headers; if (isset($total_items)) { $response['total_items_i18n'] = sprintf(_n('1 item', '%s items', $total_items), number_format_i18n($total_items)); } if (isset($total_pages)) { $response['total_pages'] = $total_pages; $response['total_pages_i18n'] = number_format_i18n($total_pages); } die(wp_json_encode($response)); }
/** * Add Custom Post Types and Taxonomies to "At a Glance" Dashboard Widget * * Ref Link: http://wpsnipp.com/index.php/functions-php/include-custom-post-types-in-right-now-admin-dashboard-widget/ * http://wordpress.org/support/topic/dashboard-at-a-glance-custom-post-types * http://halfelf.org/2012/my-custom-posttypes-live-in-mu/ */ function seventeen_right_now_content_table_end() { $args = array('public' => true, '_builtin' => false); $output = 'object'; $operator = 'and'; $post_types = get_post_types($args, $output, $operator); foreach ($post_types as $post_type) { $num_posts = wp_count_posts($post_type->name); $num = number_format_i18n($num_posts->publish); $text = _n($post_type->labels->name, $post_type->labels->name, intval($num_posts->publish)); if (current_user_can('edit_posts')) { $cpt_name = $post_type->name; } echo '<li class="post-count ' . $post_type->name . '-count"><tr><a href="edit.php?post_type=' . $cpt_name . '"><td class="first b b-' . $post_type->name . '"></td>' . $num . ' <td class="t ' . $post_type->name . '">' . $text . '</td></a></tr></li>'; } $taxonomies = get_taxonomies($args, $output, $operator); foreach ($taxonomies as $taxonomy) { $num_terms = wp_count_terms($taxonomy->name); $num = number_format_i18n($num_terms); $text = _n($taxonomy->labels->name, $taxonomy->labels->name, intval($num_terms)); if (current_user_can('manage_categories')) { $cpt_tax = $taxonomy->name; } echo '<li class="taxonomy-count ' . $taxonomy->name . '-count"><tr><a href="edit-tags.php?taxonomy=' . $cpt_tax . '"><td class="first b b-' . $taxonomy->name . '"></td>' . $num . ' <td class="t ' . $taxonomy->name . '">' . $text . '</td></a></tr></li>'; } }
/** * @see Rule::getActions() **/ function getActions() { $actions = array(); $actions['name']['name'] = _n('Version', 'Versions', 1); $actions['name']['force_actions'] = array('append_regex_result', 'assign', 'regex_result'); return $actions; }
/** * @param $model PluginDatainjectionModel object * @param $canedit (false by default) **/ static function showAddInfo(PluginDatainjectionModel $model, $canedit = false) { if ($canedit) { echo "<form method='post' name='form' id='form' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th>" . __('Tables', 'datainjection') . "</th>"; echo "<th>" . _n('Field', 'Fields', 2) . "</th>"; echo "<th>" . __('Mandatory information', 'datainjection') . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td class='center'>"; $infos_id = -1; $info = new PluginDatainjectionInfo(); $info->fields['id'] = -1; $info->fields['models_id'] = $model->fields['id']; $info->getEmpty(); $rand = PluginDatainjectionInjectionType::dropdownLinkedTypes($info, array('primary_type' => $model->fields['itemtype'])); echo "</td>"; echo "<td class='center'><span id='span_field_{$infos_id}'></span></td>"; echo "<td class='center'><span id='span_mandatory_{$infos_id}'></span></td>"; echo "</tr>"; echo "<tr>"; echo "<td class='tab_bg_2 center' colspan='4'>"; echo "<input type='hidden' name='models_id' value='" . $model->fields['id'] . "'>"; echo "<input type='submit' name='update' value='" . _sx('button', 'Add') . "' class='submit' >"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "<br/>"; } }
/** * Regenerate thumbnails for one or more attachments. * * ## OPTIONS * * [<attachment-id>...] * : One or more IDs of the attachments to regenerate. * * [--skip-delete] * : Skip deletion of the original thumbnails. If your thumbnails are linked from sources outside your control, it's likely best to leave them around. Defaults to false. * * [--only-missing] * : Only generate thumbnails for images missing image sizes. * * [--yes] * : Answer yes to the confirmation message. Confirmation only shows when no IDs passed as arguments. * * ## EXAMPLES * * # Regenerate thumbnails for given attachment IDs. * $ wp media regenerate 123 124 125 * Found 3 images to regenerate. * 1/3 Regenerated thumbnails for "Vertical Image" (ID 123). * 2/3 Regenerated thumbnails for "Horizontal Image" (ID 124). * 3/3 Regenerated thumbnails for "Beautiful Picture" (ID 125). * Success: Regenerated 3 of 3 images. * * # Regenerate all thumbnails, without confirmation. * $ wp media regenerate --yes * Found 3 images to regenerate. * 1/3 Regenerated thumbnails for "Sydney Harbor Bridge" (ID 760). * 2/3 Regenerated thumbnails for "Boardwalk" (ID 757). * 3/3 Regenerated thumbnails for "Sunburst Over River" (ID 756). * Success: Regenerated 3 of 3 images. * * # Re-generate all thumbnails that have IDs between 1000 and 2000. * $ seq 1000 2000 | xargs wp media regenerate * Found 4 images to regenerate. * 1/4 Regenerated thumbnails for "Vertical Featured Image" (ID 1027). * 2/4 Regenerated thumbnails for "Horizontal Featured Image" (ID 1022). * 3/4 Regenerated thumbnails for "Unicorn Wallpaper" (ID 1045). * 4/4 Regenerated thumbnails for "I Am Worth Loving Wallpaper" (ID 1023). * Success: Regenerated 4 of 4 images. */ function regenerate($args, $assoc_args = array()) { if (empty($args)) { WP_CLI::confirm('Do you really want to regenerate all images?', $assoc_args); } $skip_delete = \WP_CLI\Utils\get_flag_value($assoc_args, 'skip-delete'); $only_missing = \WP_CLI\Utils\get_flag_value($assoc_args, 'only-missing'); if ($only_missing) { $skip_delete = true; } $query_args = array('post_type' => 'attachment', 'post__in' => $args, 'post_mime_type' => 'image', 'post_status' => 'any', 'posts_per_page' => -1, 'fields' => 'ids'); $images = new WP_Query($query_args); $count = $images->post_count; if (!$count) { WP_CLI::warning('No images found.'); return; } WP_CLI::log(sprintf('Found %1$d %2$s to regenerate.', $count, _n('image', 'images', $count))); $errored = false; $successes = $errors = 0; foreach ($images->posts as $number => $id) { if ($this->process_regeneration($id, $skip_delete, $only_missing, $number + 1 . '/' . $count)) { $successes++; } else { $errors++; } } Utils\report_batch_operation_results('image', 'regenerate', count($images->posts), $successes, $errors); }
/** * Generate the add/remove a topic to/from bookmark list link. * * @since 0.0.1 */ function vp_bookmark() { if (!is_user_logged_in() || !is_single()) { return; } $topic_id = get_the_ID(); $user_id = wp_get_current_user()->ID; $bookmarked_num = 0; // Which users already bookmarked this topic $bookmarked = (array) get_post_meta($topic_id, 'v2press_who_bookmarked_me', true); if ('' != $bookmarked[0]) { $bookmarked_num = count($bookmarked); } if (in_array($user_id, $bookmarked)) { $action = 'remove'; $text = __('Remove from Bookmark', 'v2press'); } else { $action = 'add'; $text = __('Add to Bookmark', 'v2press'); } $output = '<div class="favorite-topic">'; if (0 < $bookmarked_num) { $output .= sprintf(_n('%d user bookmarked', '%d users bookmarked', $bookmarked_num, 'v2press'), $bookmarked_num); } $output .= '<a class="fav ' . $action . '" href="?bookmark=' . $action . '&topic=' . $topic_id . '" title="' . esc_attr($text) . '">' . $text . '</a>'; $output .= '</div>'; echo $output; }
function showForm($target) { global $DB; $rand = mt_rand(); $query = "SELECT *\n FROM `" . $this->getTable() . "`\n ORDER BY `states_id` ASC "; if ($result = $DB->query($query)) { $number = $DB->numrows($result); if ($number != 0) { echo "<div align='center'><form method='post' name='massiveaction_form{$rand}' id='massiveaction_form{$rand}' action=\"{$target}\">"; echo "<table class='tab_cadre_fixe' cellpadding='5'>"; echo "<tr>"; echo "<th></th><th>" . _n('Status', 'Statuses', 2) . "</th>"; echo "</tr>"; while ($ligne = $DB->fetch_array($result)) { $ID = $ligne["id"]; echo "<tr class='tab_bg_1'>"; echo "<td width='10' class='center'>"; echo "<input type='hidden' name='id' value='{$ID}'>"; echo "<input type='checkbox' name='item[{$ID}]' value='1'>"; echo "</td>"; echo "<td>" . Dropdown::getDropdownName("glpi_states", $ligne["states_id"]) . "</td>"; echo "</tr>"; } Html::openArrowMassives("massiveaction_form{$rand}", true); Html::closeArrowMassives(array('delete_state' => __('Delete permanently'))); echo "</table>"; Html::closeForm(); echo "</div>"; } } }
function menu_pages() { if (!$this->menu_page_exists('ajaxy-page')) { add_menu_page(_n('Ajaxy', 'Ajaxy', 1, 'ajaxy'), _n('Ajaxy', 'Ajaxy', 1), 'Ajaxy', 'ajaxy-page', array(&$this, 'overview'), AJAXY_SF_PLUGIN_URL . '/images/ico.png'); } add_submenu_page('ajaxy-page', __('Live Search'), __('Live Search'), 'manage_options', 'ajaxy_sf_admin', array(&$this, 'admin_page')); }
/** * Regenerate thumbnail(s). * * ## OPTIONS * * [<attachment-id>...] * : One or more IDs of the attachments to regenerate. * * [--skip-delete] * : Skip deletion of the original thumbnails. If your thumbnails are linked from sources outside your control, it's likely best to leave them around. Defaults to false. * * [--only-missing] * : Only generate thumbnails for images missing image sizes. * * [--yes] * : Answer yes to the confirmation message. * * ## EXAMPLES * * # re-generate all thumbnails, without confirmation * wp media regenerate --yes * * # re-generate all thumbnails that have IDs between 1000 and 2000 * seq 1000 2000 | xargs wp media regenerate */ function regenerate($args, $assoc_args = array()) { if (empty($args)) { WP_CLI::confirm('Do you really want to regenerate all images?', $assoc_args); } $skip_delete = \WP_CLI\Utils\get_flag_value($assoc_args, 'skip-delete'); $only_missing = \WP_CLI\Utils\get_flag_value($assoc_args, 'only-missing'); if ($only_missing) { $skip_delete = true; } $query_args = array('post_type' => 'attachment', 'post__in' => $args, 'post_mime_type' => 'image', 'post_status' => 'any', 'posts_per_page' => -1, 'fields' => 'ids'); $images = new WP_Query($query_args); $count = $images->post_count; if (!$count) { WP_CLI::warning('No images found.'); return; } WP_CLI::log(sprintf('Found %1$d %2$s to regenerate.', $count, _n('image', 'images', $count))); $errored = false; foreach ($images->posts as $id) { if (!$this->_process_regeneration($id, $skip_delete, $only_missing)) { $errored = true; } } if ($errored) { WP_CLI::log(_n('An error occurred with image regeneration.', 'An error occurred regenerating one or more images.', $count)); } else { WP_CLI::success(sprintf('Finished regenerating %1$s.', _n('the image', 'all images', $count))); } }
/** * Cart Link * Displayed a link to the cart including the number of items present and the cart total * * @since 2.2.6 * * @param array $settings Settings * * @return array Settings */ function odin_cart_link() { if (is_cart()) { $class = 'current-menu-item active'; } else { $class = ''; } ?> <li class="<?php echo esc_attr($class); ?> "> <a class="cart-contents" href="<?php echo esc_url(WC()->cart->get_cart_url()); ?> " title="<?php _e('View your shopping cart', 'odin'); ?> "> <?php echo wp_kses_data(WC()->cart->get_cart_total()); ?> <span class="count"><?php echo wp_kses_data(sprintf(_n('%d item', '%d items', WC()->cart->get_cart_contents_count(), 'odin'), WC()->cart->get_cart_contents_count())); ?> </span> </a> </li> <?php }
/** * Displays listing package custom columns data. * * @param string $column_index * @param int $post_id * * @return void */ function cp_package_listing_add_column_data($column_index, $post_id) { $package = cp_get_listing_package($post_id); if (!$package) { return; } switch ($column_index) { case 'description': echo strip_tags($package->description); break; case 'price': appthemes_display_price($package->price); break; case 'duration': printf(_n('%d day', '%d days', $package->duration, APP_TD), $package->duration); break; case 'status': if ($package->post_status == 'publish') { _e('Active', APP_TD); } else { _e('Inactive', APP_TD); } break; } }
/** * Styles & Scripts conditional loading * * @param * $hook */ public function load_styles_scripts() { $lang = get_bloginfo('language'); $lang = explode('-', $lang); $lang = $lang[0]; /* * Item reports Styles & Scripts */ if (GADWP_Tools::check_roles($this->gadwp->config->options['ga_dash_access_front']) && $this->gadwp->config->options['frontend_item_reports']) { wp_enqueue_style('gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.css', null, GADWP_CURRENT_VERSION); wp_enqueue_style('gadwp-frontend-item-reports', GADWP_URL . 'front/css/item-reports.css', null, GADWP_CURRENT_VERSION); $country_codes = GADWP_Tools::get_countrycodes(); if ($this->gadwp->config->options['ga_target_geomap'] && isset($country_codes[$this->gadwp->config->options['ga_target_geomap']])) { $region = $this->gadwp->config->options['ga_target_geomap']; } else { $region = false; } wp_enqueue_style("wp-jquery-ui-dialog"); if (!wp_script_is('googlejsapi')) { wp_register_script('googlejsapi', 'https://www.google.com/jsapi?autoload=%7B%22modules%22%3A%5B%7B%22name%22%3A%22visualization%22%2C%22version%22%3A%221%22%2C%22language%22%3A%22' . $lang . '%22%2C%22packages%22%3A%5B%22corechart%22%2C%20%22table%22%2C%20%22orgchart%22%2C%20%22geochart%22%5D%7D%5D%7D%27', array(), null); } wp_enqueue_script('gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.js', array('jquery'), GADWP_CURRENT_VERSION); wp_enqueue_script('gadwp-frontend-item-reports', GADWP_URL . 'common/js/reports.js', array('gadwp-nprogress', 'googlejsapi', 'jquery', 'jquery-ui-dialog'), GADWP_CURRENT_VERSION); /* @formatter:off */ wp_localize_script('gadwp-frontend-item-reports', 'gadwpItemData', array('ajaxurl' => admin_url('admin-ajax.php'), 'security' => wp_create_nonce('gadwp_frontend_item_reports'), 'dateList' => array('today' => __("Today", 'google-analytics-dashboard-for-wp'), 'yesterday' => __("Yesterday", 'google-analytics-dashboard-for-wp'), '7daysAgo' => sprintf(__("Last %d Days", 'google-analytics-dashboard-for-wp'), 7), '14daysAgo' => sprintf(__("Last %d Days", 'google-analytics-dashboard-for-wp'), 14), '30daysAgo' => sprintf(__("Last %d Days", 'google-analytics-dashboard-for-wp'), 30), '90daysAgo' => sprintf(__("Last %d Days", 'google-analytics-dashboard-for-wp'), 90), '365daysAgo' => sprintf(_n("%s Year", "%s Years", 1, 'google-analytics-dashboard-for-wp'), __('One', 'google-analytics-dashboard-for-wp')), '1095daysAgo' => sprintf(_n("%s Year", "%s Years", 3, 'google-analytics-dashboard-for-wp'), __('Three', 'google-analytics-dashboard-for-wp'))), 'reportList' => array('uniquePageviews' => __("Unique Views", 'google-analytics-dashboard-for-wp'), 'users' => __("Users", 'google-analytics-dashboard-for-wp'), 'organicSearches' => __("Organic", 'google-analytics-dashboard-for-wp'), 'pageviews' => __("Page Views", 'google-analytics-dashboard-for-wp'), 'visitBounceRate' => __("Bounce Rate", 'google-analytics-dashboard-for-wp'), 'locations' => __("Location", 'google-analytics-dashboard-for-wp'), 'referrers' => __("Referrers", 'google-analytics-dashboard-for-wp'), 'searches' => __("Searches", 'google-analytics-dashboard-for-wp'), 'trafficdetails' => __("Traffic", 'google-analytics-dashboard-for-wp'), 'technologydetails' => __("Technology", 'google-analytics-dashboard-for-wp')), 'i18n' => array(__("A JavaScript Error is blocking plugin resources!", 'google-analytics-dashboard-for-wp'), __("Traffic Mediums", 'google-analytics-dashboard-for-wp'), __("Visitor Type", 'google-analytics-dashboard-for-wp'), __("Search Engines", 'google-analytics-dashboard-for-wp'), __("Social Networks", 'google-analytics-dashboard-for-wp'), __("Unique Views", 'google-analytics-dashboard-for-wp'), __("Users", 'google-analytics-dashboard-for-wp'), __("Page Views", 'google-analytics-dashboard-for-wp'), __("Bounce Rate", 'google-analytics-dashboard-for-wp'), __("Organic Search", 'google-analytics-dashboard-for-wp'), __("Pages/Session", 'google-analytics-dashboard-for-wp'), __("Invalid response, more details in JavaScript Console (F12).", 'google-analytics-dashboard-for-wp'), __("Not enough data collected", 'google-analytics-dashboard-for-wp'), __("This report is unavailable", 'google-analytics-dashboard-for-wp'), __("report generated by", 'google-analytics-dashboard-for-wp'), __("This plugin needs an authorization:", 'google-analytics-dashboard-for-wp') . ' <strong>' . __("authorize the plugin", 'google-analytics-dashboard-for-wp') . '</strong>!', __("Browser", 'google-analytics-dashboard-for-wp'), __("Operating System", 'google-analytics-dashboard-for-wp'), __("Screen Resolution", 'google-analytics-dashboard-for-wp'), __("Mobile Brand", 'google-analytics-dashboard-for-wp')), 'colorVariations' => GADWP_Tools::variations($this->gadwp->config->options['ga_dash_style']), 'region' => $region, 'language' => get_bloginfo('language'), 'filter' => $_SERVER["REQUEST_URI"], 'viewList' => false, 'scope' => 'front-item')); /* @formatter:on */ } }
static function showFormAlerts($target) { $self = new self(); $self->getFromDB(1); echo "<form action='{$target}' method='post'>"; echo "<input type='hidden' name='id' value='1'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Reminders frequency', 'additionalalerts') . " " . PluginAdditionalalertsInfocomAlert::getTypeName(2) . "</td><td>"; Alert::dropdownYesNo(array('name' => "use_infocom_alert", 'value' => $self->fields["use_infocom_alert"])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td >" . __('Reminders frequency', 'additionalalerts') . " " . __('New imported computers from OCS-NG', 'additionalalerts') . "</td><td>"; Alert::dropdownYesNo(array('name' => "use_newocs_alert", 'value' => $self->fields["use_newocs_alert"])); echo "</td></tr>"; echo "<tr class='tab_bg_2'><td >" . __('OCS-NG Synchronization alerts', 'additionalalerts') . "</td><td>"; Alert::dropdownIntegerNever('delay_ocs', $self->fields["delay_ocs"], array('max' => 99)); echo " " . _n('Day', 'Days', 2) . "</td></tr>"; echo "</td></tr>"; echo "<tr class='tab_bg_2'><td class='center' colspan='2'>"; echo "<input type='hidden' name='id' value='1'>"; echo "<input class='submit' type='submit' name='update' value='" . _sx('button', 'Save') . "'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); }
function wp_star_rating($args = array()) { $defaults = array('rating' => 0, 'type' => 'rating', 'number' => 0); $r = wp_parse_args($args, $defaults); // Non-english decimal places when the $rating is coming from a string $rating = str_replace(',', '.', $r['rating']); // Convert Percentage to star rating, 0..5 in .5 increments if ('percent' == $r['type']) { $rating = round($rating / 10, 0) / 2; } // Calculate the number of each type of star needed $full_stars = floor($rating); $half_stars = ceil($rating - $full_stars); $empty_stars = 5 - $full_stars - $half_stars; if ($r['number']) { /* translators: 1: The rating, 2: The number of ratings */ $format = _n('%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $r['number']); $title = sprintf($format, number_format_i18n($rating, 1), number_format_i18n($r['number'])); } else { /* translators: 1: The rating */ $title = sprintf(__('%s rating'), number_format_i18n($rating, 1)); } echo '<div class="star-rating" title="' . esc_attr($title) . '">'; echo '<span class="screen-reader-text">' . $title . '</span>'; echo str_repeat('<div class="star star-full"></div>', $full_stars); echo str_repeat('<div class="star star-half"></div>', $half_stars); echo str_repeat('<div class="star star-empty"></div>', $empty_stars); echo '</div>'; }
static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item) { global $DB, $CFG_GLPIG; if (!Session::haveRight("contract", "r")) { return false; } $type = $item->getType(); $ID = $item->getField('id'); $con = new Contract(); $query = "SELECT *\n FROM `glpi_contracts_items`\n WHERE `glpi_contracts_items`.`items_id` = '" . $ID . "'\n AND `glpi_contracts_items`.`itemtype` = '" . $type . "'"; $result = $DB->query($query); $number = $DB->numrows($result); $i = $j = 0; $pdf->setColumnsSize(100); if ($number > 0) { $pdf->displayTitle('<b>' . _N('Associated contract', 'Associated contracts', 2) . '</b>'); $pdf->setColumnsSize(19, 19, 19, 16, 11, 16); $pdf->displayTitle(__('Name'), _x('phone', 'Number'), __('Contract type'), __('Supplier'), __('Start date'), __('Initial contract period')); $i++; while ($j < $number) { $cID = $DB->result($result, $j, "contracts_id"); $assocID = $DB->result($result, $j, "id"); if ($con->getFromDB($cID)) { $pdf->displayLine(empty($con->fields["name"]) ? "(" . $con->fields["id"] . ")" : $con->fields["name"], $con->fields["num"], Html::clean(Dropdown::getDropdownName("glpi_contracttypes", $con->fields["contracttypes_id"])), str_replace("<br>", " ", $con->getSuppliersNames()), Html::convDate($con->fields["begin_date"]), sprintf(_n('%d month', '%d months', $con->fields["duration"]), $con->fields["duration"])); } $j++; } } else { $pdf->displayTitle("<b>" . __('No item found') . "</b>"); } $pdf->displaySpace(); }
/** * Creates a string representation of the subscription period/term for each item in the cart * * @param $price float (optional) The price to display in the subscription. Defaults to empty, which returns just the period & duration components of the string. * @since 1.0 */ public static function get_order_subscription_string($order, $price = '', $sign_up_fee = '') { if (count($order->get_items()) == 1) { $subscription_period = self::get_subscription_period($order); $subscription_length = self::get_subscription_length($order); $subscription_interval = self::get_subscription_interval($order); $subscription_trial_length = self::get_subscription_trial_length($order); $subscription_string = sprintf(_n(' %s / %s', ' %s every %s', $subscription_interval, WC_Subscriptions::$text_domain), $price, WC_Subscriptions_Manager::get_subscription_period_strings($subscription_interval, strtolower($subscription_period))); if ($subscription_length) { $ranges = WC_Subscriptions_Manager::get_subscription_ranges($subscription_period); $subscription_string = sprintf(__('%s for %s', WC_Subscriptions::$text_domain), $subscription_string, $ranges[$subscription_length]); } if ($subscription_trial_length > 0) { $trial_lengths = WC_Subscriptions_Manager::get_subscription_trial_lengths($subscription_period); $subscription_string = sprintf(__('%s with %s free trial', WC_Subscriptions::$text_domain), $subscription_string, $trial_lengths[$subscription_trial_length]); } $sign_up_fee = !empty($sign_up_fee) ? $sign_up_fee : self::get_meta($order, '_sign_up_fee_total'); if ($sign_up_fee > 0) { if (self::is_renewal($order)) { $subscription_string = sprintf(__('%s with a %s initial payment', WC_Subscriptions::$text_domain), $subscription_string, woocommerce_price($sign_up_fee)); } else { $subscription_string = sprintf(__('%s with a %s sign-up fee', WC_Subscriptions::$text_domain), $subscription_string, woocommerce_price($sign_up_fee)); } } } else { $subscription_string = __('Multiple Subscriptions', WC_Subscriptions::$text_domain); } return $subscription_string; }
public function ajax() { $apiArgs = isset($_GET["apiArgs"]) ? $_GET["apiArgs"] : array(); if (!$apiArgs) { wp_send_json_error(array("error" => "MISSING_APIARGS")); exit; } if (empty($apiArgs["since_id"]) || !is_numeric($apiArgs["since_id"])) { wp_send_json_error(array("error" => "MISSING_SINCE_ID")); exit; } // $since_id = isset( $_GET["since_id"] ) ? absint($_GET["since_id"]) : null; $logQueryArgs = $apiArgs; $logQuery = new SimpleHistoryLogQuery(); $answer = $logQuery->query($logQueryArgs); // Use our own repsonse array instead of $answer to keep size down $json_data = array(); $numNewRows = isset($answer["total_row_count"]) ? $answer["total_row_count"] : 0; $json_data["num_new_rows"] = $numNewRows; $json_data["num_mysql_queries"] = get_num_queries(); if ($numNewRows) { // We have new rows // Append strings $textRowsFound = sprintf(_n('1 new event', '%d new events', $numNewRows, 'simple-history'), $numNewRows); $json_data["strings"] = array("newRowsFound" => $textRowsFound); } wp_send_json_success($json_data); }