• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP TablePress类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中TablePress的典型用法代码示例。如果您正苦于以下问题:PHP TablePress类的具体用法?PHP TablePress怎么用?PHP TablePress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TablePress类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Init the Table model by instantiating a Post model and loading the list of tables option.
  *
  * @since 1.0.0
  */
 public function __construct()
 {
     parent::__construct();
     $this->model_post = TablePress::load_model('post');
     $params = array('option_name' => 'tablepress_tables', 'default_value' => $this->default_tables);
     $this->tables = TablePress::load_class('TablePress_WP_Option', 'class-wp_option.php', 'classes', $params);
 }
开发者ID:akumanu,项目名称:wordpress-gk,代码行数:12,代码来源:model-table.php


示例2: __construct

 /**
  * Init Options Model by creating the object instances for the Plugin and User Options.
  *
  * @since 1.0.0
  */
 public function __construct()
 {
     parent::__construct();
     $params = array('option_name' => 'tablepress_plugin_options', 'default_value' => $this->default_plugin_options);
     $this->plugin_options = TablePress::load_class('TablePress_WP_Option', 'class-wp_option.php', 'classes', $params);
     $params = array('option_name' => 'tablepress_user_options', 'default_value' => $this->default_user_options);
     $this->user_options = TablePress::load_class('TablePress_WP_User_Option', 'class-wp_user_option.php', 'classes', $params);
     // Filter to map Meta capabilities to Primitive Capabilities.
     add_filter('map_meta_cap', array($this, 'map_tablepress_meta_caps'), 10, 4);
 }
开发者ID:andrewfandrew,项目名称:bronze-boar,代码行数:15,代码来源:model-options.php


示例3: setup

 /**
  * Set up the view with data and do things that are specific for this view.
  *
  * @param string $action Action for this view.
  * @param array $data Data for this view.
  */
 public function setup($action, array $data)
 {
     $params = array('option_name' => 'tablepress_stockflock_config', 'default_value' => array());
     $this->stockflock_config = TablePress::load_class('TablePress_WP_Option', 'class-wp_option.php', 'classes', $params);
     parent::setup($action, $data);
     $this->add_header_message('<span>' . __('Please contact stockflock if you get any issue with this plugin.', 'tablepress') . '</span>', 'notice-info');
     $this->process_action_messages(array('success_save' => __('Stockflock Changes saved successfully.', 'tablepress'), 'error_save' => __('Error: Stockflock Changes could not be saved.', 'tablepress')));
     $this->add_meta_box('stockflock-options', __('Stockflock Options', 'tablepress'), array($this, 'stockflock_plugin_options'), 'normal');
     $this->add_text_box('submit', array($this, 'textbox_submit_button'), 'submit');
 }
开发者ID:hsehastian,项目名称:tablepress-stockflock,代码行数:16,代码来源:view-stockflock.php


示例4: __construct

 /**
  * Initialize all controllers, by loading Plugin and User Options, and performing an update check
  *
  * @since 1.0.0
  */
 public function __construct()
 {
     $this->model_options = TablePress::load_model('options');
     $this->model_table = TablePress::load_model('table');
     // update check, in all controllers (frontend and admin), to make sure we always have up-to-date options
     $this->plugin_update_check();
     // should be done very early
     // Admin Page Menu entry, needed for construction of plugin URLs
     $this->parent_page = apply_filters('tablepress_admin_menu_parent_page', $this->model_options->get('admin_menu_parent_page'));
     $this->is_top_level_page = in_array($this->parent_page, array('top', 'middle', 'bottom'), true);
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:16,代码来源:class-controller.php


示例5: postbox_no_tables

    /**
     * Print the content of the "No tables found" post meta box
     *
     * @since 1.0.0
     */
    public function postbox_no_tables($data, $box)
    {
        $add_url = TablePress::url(array('action' => 'add'));
        $import_url = TablePress::url(array('action' => 'import'));
        ?>
		<p><?php 
        _e('No tables found.', 'tablepress');
        ?>
</p>
		<p><?php 
        printf(__('You should <a href="%s">add</a> or <a href="%s">import</a> a table to get started!', 'tablepress'), $add_url, $import_url);
        ?>
</p>
		<?php 
    }
开发者ID:heyjones,项目名称:crossfitpurpose,代码行数:20,代码来源:view-export.php


示例6: minify_css

 /**
  * Minify a string of CSS code, that should have been sanitized/tidied before
  *
  * @since 1.1.0
  *
  * @uses CSSTidy
  *
  * @param string $css CSS code
  * @return string Minified CSS code
  */
 function minify_css($css)
 {
     $csstidy = TablePress::load_class('csstidy', 'class.csstidy.php', 'libraries/csstidy');
     $csstidy->optimise = new csstidy_custom_sanitize($csstidy);
     $csstidy->set_cfg('remove_bslash', false);
     $csstidy->set_cfg('compress_colors', true);
     $csstidy->set_cfg('compress_font-weight', true);
     $csstidy->set_cfg('lowercase_s', false);
     $csstidy->set_cfg('optimise_shorthands', 1);
     $csstidy->set_cfg('remove_last_;', true);
     $csstidy->set_cfg('case_properties', false);
     $csstidy->set_cfg('sort_properties', false);
     $csstidy->set_cfg('sort_selectors', false);
     $csstidy->set_cfg('discard_invalid_selectors', false);
     $csstidy->set_cfg('discard_invalid_properties', true);
     $csstidy->set_cfg('merge_selectors', false);
     $csstidy->set_cfg('css_level', 'CSS3.0');
     $csstidy->set_cfg('preserve_css', false);
     $csstidy->set_cfg('timestamp', false);
     $csstidy->set_cfg('template', 'highest');
     $csstidy->parse($css);
     return $csstidy->print->plain();
 }
开发者ID:heyjones,项目名称:crossfitpurpose,代码行数:33,代码来源:class-css.php


示例7: print_nav_tab_menu

    /**
     * Render the navigation menu with links to the possible actions, highlighting the current one.
     *
     * @since 1.0.0
     */
    protected function print_nav_tab_menu()
    {
        ?>
		<h1 id="tablepress-nav" class="nav-tab-wrapper">
			<?php 
        echo '<span class="plugin-name">' . __('TablePress', 'tablepress') . '</span><span class="separator"></span>';
        foreach ($this->data['view_actions'] as $action => $entry) {
            // Special case: Add a separator before the group that starts with "Plugin Options", for some spacing.
            if ('options' === $action) {
                echo '<span class="separator"></span><span class="separator"></span>';
            }
            if ('' === $entry['nav_tab_title']) {
                continue;
            }
            if (!current_user_can($entry['required_cap'])) {
                continue;
            }
            $url = esc_url(TablePress::url(array('action' => $action)));
            $active = $action === $this->action ? ' nav-tab-active' : '';
            echo "<a class=\"nav-tab{$active}\" href=\"{$url}\">{$entry['nav_tab_title']}</a>";
        }
        ?>
		</h1>
		<?php 
    }
开发者ID:akumanu,项目名称:wordpress-gk,代码行数:30,代码来源:class-view.php


示例8: ajax_action_preview_table

 /**
  * Return the live preview data of table that has non-saved changes.
  *
  * @since 1.0.0
  */
 public function ajax_action_preview_table()
 {
     if (empty($_POST['tablepress']) || empty($_POST['tablepress']['id'])) {
         wp_die('-1');
     } else {
         $preview_table = wp_unslash($_POST['tablepress']);
     }
     // Check if the submitted nonce matches the generated nonce we created earlier, dies -1 on failure.
     TablePress::check_nonce('preview_table', $preview_table['id'], '_ajax_nonce', true);
     // Ignore the request if the current user doesn't have sufficient permissions.
     if (!current_user_can('tablepress_preview_table', $preview_table['id'])) {
         wp_die('-1');
     }
     // Default response data.
     $success = false;
     do {
         // to be able to "break;" (allows for better readable code)
         // Load table, without table data, but with options and visibility settings.
         $existing_table = TablePress::$model_table->load($preview_table['id'], false, true);
         if (is_wp_error($existing_table)) {
             // maybe somehow load a new table here? (TablePress::$model_table->get_table_template())?
             break;
         }
         // Check and convert data that was transmitted as JSON.
         if (empty($preview_table['data']) || empty($preview_table['options']) || empty($preview_table['visibility'])) {
             break;
         }
         $preview_table['data'] = (array) json_decode($preview_table['data'], true);
         $preview_table['options'] = (array) json_decode($preview_table['options'], true);
         $preview_table['visibility'] = (array) json_decode($preview_table['visibility'], true);
         // Check consistency of new table, and then merge with existing table.
         $table = TablePress::$model_table->prepare_table($existing_table, $preview_table, true, true);
         if (is_wp_error($table)) {
             break;
         }
         // DataTables Custom Commands can only be edit by trusted users.
         if (!current_user_can('unfiltered_html')) {
             $table['options']['datatables_custom_commands'] = $existing_table['options']['datatables_custom_commands'];
         }
         // If the ID has changed, and the new ID is valid, render with the new ID (important e.g. for CSS classes/HTML ID).
         if ($table['id'] !== $table['new_id'] && 0 === preg_match('/[^a-zA-Z0-9_-]/', $table['new_id'])) {
             $table['id'] = $table['new_id'];
         }
         // Sanitize all table data to remove unsafe HTML from the preview output.
         $table = TablePress::$model_table->sanitize($table);
         // At this point, the table data is valid and sanitized and can be rendered.
         $success = true;
     } while (false);
     // Do-while-loop through this exactly once, to be able to "break;" early.
     // Initialize i18n support, load plugin's textdomain, to retrieve correct translations for the description of the preview.
     load_plugin_textdomain('tablepress', false, dirname(TABLEPRESS_BASENAME) . '/i18n');
     if ($success) {
         // Create a render class instance.
         $_render = TablePress::load_class('TablePress_Render', 'class-render.php', 'classes');
         // Merge desired options with default render options (see TablePress_Controller_Frontend::shortcode_table()).
         $default_render_options = $_render->get_default_render_options();
         /** This filter is documented in controllers/controller-frontend.php */
         $default_render_options = apply_filters('tablepress_shortcode_table_default_shortcode_atts', $default_render_options);
         $render_options = shortcode_atts($default_render_options, $table['options']);
         /** This filter is documented in controllers/controller-frontend.php */
         $render_options = apply_filters('tablepress_shortcode_table_shortcode_atts', $render_options);
         $_render->set_input($table, $render_options);
         $head_html = $_render->get_preview_css();
         $custom_css = TablePress::$model_options->get('custom_css');
         if (!empty($custom_css)) {
             $head_html .= "<style type=\"text/css\">\n{$custom_css}\n</style>\n";
         }
         $body_html = '<div id="tablepress-page"><p>' . __('This is a preview of your table.', 'tablepress') . ' ' . __('Because of CSS styling in your theme, the table might look different on your page!', 'tablepress') . ' ' . __('The features of the DataTables JavaScript library are also not available or visible in this preview!', 'tablepress') . '<br />' . sprintf(__('To insert the table into a page, post, or text widget, copy the Shortcode %s and paste it into the editor.', 'tablepress'), '<input type="text" class="table-shortcode table-shortcode-inline" value="' . esc_attr('[' . TablePress::$shortcode . " id={$table['id']} /]") . '" readonly="readonly" />') . '</p>' . $_render->get_output() . '</div>';
     } else {
         $head_html = '';
         $body_html = __('The preview could not be loaded.', 'tablepress');
     }
     // Generate the response.
     $response = array('success' => $success, 'head_html' => $head_html, 'body_html' => $body_html);
     // Buffer all outputs, to prevent errors/warnings being printed that make the JSON invalid.
     $output_buffer = ob_get_clean();
     if (!empty($output_buffer)) {
         $response['output_buffer'] = $output_buffer;
     }
     // Send the response.
     wp_send_json($response);
 }
开发者ID:pedro-mendonca,项目名称:TablePress,代码行数:87,代码来源:controller-admin_ajax.php


示例9: shortcode_table_info

 /**
  * Handle Shortcode [table-info id=<ID> field=<name> /] in the_content()
  *
  * @since 1.0.0
  *
  * @param array $atts list of attributes that where included in the Shortcode
  * @return string Text that replaces the Shortcode (error message or asked-for information)
  */
 public function shortcode_table_info($shortcode_atts)
 {
     // parse Shortcode attributes, only allow those that are specified
     $default_shortcode_atts = array('id' => 0, 'field' => '', 'format' => '');
     $default_shortcode_atts = apply_filters('tablepress_shortcode_table_info_default_shortcode_atts', $default_shortcode_atts);
     $shortcode_atts = shortcode_atts($default_shortcode_atts, $shortcode_atts);
     $shortcode_atts = apply_filters('tablepress_shortcode_table_info_shortcode_atts', $shortcode_atts);
     // allow a filter to determine behavior of this function, by overwriting its behavior, just need to return something other than false
     $overwrite = apply_filters('tablepress_shortcode_table_info_overwrite', false, $shortcode_atts);
     if ($overwrite) {
         return $overwrite;
     }
     // check, if a table with the given ID exists
     $table_id = preg_replace('/[^a-zA-Z0-9_-]/', '', $shortcode_atts['id']);
     if (!$this->model_table->table_exists($table_id)) {
         $message = "[table &#8220;{$table_id}&#8221; not found /]<br />\n";
         $message = apply_filters('tablepress_table_not_found_message', $message, $table_id);
         return $message;
     }
     // load the table
     $table = $this->model_table->load($table_id);
     if (false === $table) {
         $message = "[table &#8220;{$table_id}&#8221; could not be loaded /]<br />\n";
         $message = apply_filters('tablepress_table_load_error_message', $message, $table_id);
         return $message;
     }
     $field = preg_replace('/[^a-z_]/', '', strtolower($shortcode_atts['field']));
     $format = preg_replace('/[^a-z]/', '', strtolower($shortcode_atts['format']));
     // generate output, depending on what information (field) was asked for
     switch ($field) {
         case 'name':
         case 'description':
             $output = $table[$field];
             break;
         case 'last_modified':
             switch ($format) {
                 case 'raw':
                     $output = $table['last_modified'];
                     break 2;
                 case 'mysql':
                     $output = TablePress::format_datetime($table['last_modified'], 'mysql', ' ');
                     break 2;
                 case 'human':
                     $modified_timestamp = strtotime($table['last_modified']);
                     $current_timestamp = current_time('timestamp');
                     $time_diff = $current_timestamp - $modified_timestamp;
                     if ($time_diff >= 0 && $time_diff < DAY_IN_SECONDS) {
                         // time difference is only shown up to one day
                         $output = sprintf(__('%s ago', 'tablepress'), human_time_diff($modified_timestamp, $current_timestamp));
                     } else {
                         $output = TablePress::format_datetime($table['last_modified'], 'mysql', '<br />');
                     }
                     break 2;
                 default:
                     $output = TablePress::format_datetime($table['last_modified'], 'mysql', ' ');
             }
             break;
         case 'last_editor':
             $output = TablePress::get_user_display_name($table['options']['last_editor']);
             break;
         case 'author':
             $output = TablePress::get_user_display_name($table['author']);
             break;
         default:
             $output = "[table-info field &#8220;{$field}&#8221; not found in table &#8220;{$table_id}&#8221; /]<br />\n";
             $output = apply_filters('tablepress_table_info_not_found_message', $output, $table, $field, $format);
     }
     $output = apply_filters('tablepress_shortcode_table_info_output', $output, $table, $shortcode_atts);
     return $output;
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:78,代码来源:controller-frontend.php


示例10: test_url_toplevel

 /**
  * Test that the screen URLs for toplevel admin menu entries are correct.
  *
  * @since 1.1.0
  */
 public function test_url_toplevel()
 {
     TablePress::$controller->is_top_level_page = true;
     TablePress::$controller->parent_page = 'middle';
     $this->assertSame('http://example.org/wp-admin/admin.php?page=tablepress', TablePress::url());
     $this->assertSame('http://example.org/wp-admin/admin.php?page=tablepress', TablePress::url(array(), false));
 }
开发者ID:pedro-mendonca,项目名称:TablePress,代码行数:12,代码来源:test-utils.php


示例11: handle_post_action_stockflock

 /**
  * Save changes on the Stockflock screen.
  *
  */
 public function handle_post_action_stockflock()
 {
     if (!isset($_POST['stockflock'])) {
         return;
     }
     TablePress::check_nonce('stockflock');
     if (!current_user_can('manage_options')) {
         wp_die(__('You do not have sufficient permissions to access this page.'));
     }
     if (empty($_POST['stockflock']) || !is_array($_POST['stockflock'])) {
         TablePress::redirect(array('action' => 'stockflock', 'message' => 'error_save'));
     } else {
         $stockflock = stripslashes_deep($_POST['stockflock']);
     }
     $params = array('option_name' => 'tablepress_stockflock_config', 'default_value' => array());
     $stockflock_config = TablePress::load_class('TablePress_WP_Option', 'class-wp_option.php', 'classes', $params);
     //trim and restrict array length to be not more than 20
     $raw_companies = explode(',', $stockflock['companies']);
     $valid_companies = array_slice(array_map('trim', $raw_companies), 0, $this->company_limit);
     $stockflock['companies'] = strtoupper(implode(',', $valid_companies));
     //give default value to data_points
     $data_point_list = ['short_name', 'price_value', 'industry_name', 'dividend_yield', 'earning_value', 'dividend_per_share', 'book_value', 'debt_assets', 'net_asset_value', 'gearing_ratio', 'property_yield_ratio'];
     if (is_array($stockflock['data_points'])) {
         foreach ($data_point_list as $key => $value) {
             if (!array_key_exists($value, $stockflock['data_points'])) {
                 $stockflock['data_points'][$value] = "false";
             }
         }
     }
     //store to wp_options
     $stockflock_config->update($stockflock);
     TablePress::redirect(array('action' => 'stockflock', 'message' => 'success_save'));
 }
开发者ID:hsehastian,项目名称:tablepress-stockflock,代码行数:37,代码来源:tablepress-stockflock.php


示例12: textbox_corrupted_table

    /**
     * Print a notification about a corrupted table
     *
     * @since 1.4.0
     */
    public function textbox_corrupted_table($data, $box)
    {
        ?>
		<div class="error">
			<p><strong><?php 
        _e('Attention: Unfortunately, an error occured.', 'tablepress');
        ?>
</strong></p>
			<p>
				<?php 
        printf(__('The internal data of table &#8220;%1$s&#8221 (ID %2$s) is corrupted.', 'tablepress'), esc_html($data['table']['name']), esc_html($data['table']['id']));
        echo ' ';
        printf(__('The following error was registered: <code>%s</code>.', 'tablepress'), esc_html($data['table']['json_error']));
        ?>
			</p>
			<p>
				<?php 
        _e('Because of this error, the table can not be edited at this time, to prevent possible further data loss.', 'tablepress');
        echo ' ';
        printf(__('Please see the <a href="%s">TablePress FAQ page</a> for further instructions.', 'tablepress'), 'http://tablepress.org/faq/corrupted-tables/');
        ?>
			</p>
			<p>
				<?php 
        echo '<a href="' . TablePress::url(array('action' => 'list')) . '" class="button">' . __('Back to the List of Tables', 'tablepress') . '</a>';
        ?>
			</p>
		</div>
		<?php 
    }
开发者ID:heyjones,项目名称:crossfitpurpose,代码行数:35,代码来源:view-edit.php


示例13: shortcode_table_info

 /**
  * Handle Shortcode [table-info id=<ID> field=<name> /] in the_content()
  *
  * @since 1.0.0
  *
  * @param array $shortcode_atts List of attributes that where included in the Shortcode
  * @return string Text that replaces the Shortcode (error message or asked-for information)
  */
 public function shortcode_table_info($shortcode_atts)
 {
     // For empty Shortcodes like [table-info] or [table-info /], an empty string is passed, see Core #26927
     $shortcode_atts = (array) $shortcode_atts;
     // parse Shortcode attributes, only allow those that are specified
     $default_shortcode_atts = array('id' => '', 'field' => '', 'format' => '');
     /**
      * Filter the available/default attributes for the [table-info] Shortcode.
      *
      * @since 1.0.0
      *
      * @param array $default_shortcode_atts The [table-info] Shortcode default attributes.
      */
     $default_shortcode_atts = apply_filters('tablepress_shortcode_table_info_default_shortcode_atts', $default_shortcode_atts);
     $shortcode_atts = shortcode_atts($default_shortcode_atts, $shortcode_atts);
     // Optional third argument left out on purpose. Use filter in the next line instead.
     /**
      * Filter the attributes that were passed to the [table-info] Shortcode.
      *
      * @since 1.0.0
      *
      * @param array $shortcode_atts The attributes passed to the [table-info] Shortcode.
      */
     $shortcode_atts = apply_filters('tablepress_shortcode_table_info_shortcode_atts', $shortcode_atts);
     /**
      * Filter whether the output of the [table-info] Shortcode is overwritten/short-circuited.
      *
      * @since 1.0.0
      *
      * @param bool|string $overwrite      Whether the [table-info] output is overwritten. Return false for the regular content, and a string to overwrite the output.
      * @param array       $shortcode_atts The attributes passed to the [table-info] Shortcode.
      */
     $overwrite = apply_filters('tablepress_shortcode_table_info_overwrite', false, $shortcode_atts);
     if ($overwrite) {
         return $overwrite;
     }
     // check, if a table with the given ID exists
     $table_id = preg_replace('/[^a-zA-Z0-9_-]/', '', $shortcode_atts['id']);
     if (!TablePress::$model_table->table_exists($table_id)) {
         $message = "[table &#8220;{$table_id}&#8221; not found /]<br />\n";
         /** This filter is documented in controllers/controller-frontend.php */
         $message = apply_filters('tablepress_table_not_found_message', $message, $table_id);
         return $message;
     }
     // load the table
     $table = TablePress::$model_table->load($table_id, true, true);
     // Load table, with table data, options, and visibility settings
     if (is_wp_error($table)) {
         $message = "[table &#8220;{$table_id}&#8221; could not be loaded /]<br />\n";
         /** This filter is documented in controllers/controller-frontend.php */
         $message = apply_filters('tablepress_table_load_error_message', $message, $table_id, $table);
         return $message;
     }
     $field = preg_replace('/[^a-z_]/', '', strtolower($shortcode_atts['field']));
     $format = preg_replace('/[^a-z]/', '', strtolower($shortcode_atts['format']));
     // generate output, depending on what information (field) was asked for
     switch ($field) {
         case 'name':
         case 'description':
             $output = $table[$field];
             break;
         case 'last_modified':
             switch ($format) {
                 case 'raw':
                     $output = $table['last_modified'];
                     break 2;
                 case 'human':
                     $modified_timestamp = strtotime($table['last_modified']);
                     $current_timestamp = current_time('timestamp');
                     $time_diff = $current_timestamp - $modified_timestamp;
                     if ($time_diff >= 0 && $time_diff < DAY_IN_SECONDS) {
                         // time difference is only shown up to one day
                         $output = sprintf(__('%s ago', 'tablepress'), human_time_diff($modified_timestamp, $current_timestamp));
                     } else {
                         $output = TablePress::format_datetime($table['last_modified'], 'mysql', '<br />');
                     }
                     break 2;
                 case 'mysql':
                 default:
                     $output = TablePress::format_datetime($table['last_modified'], 'mysql', ' ');
                     break 2;
             }
             break;
         case 'last_editor':
             $output = TablePress::get_user_display_name($table['options']['last_editor']);
             break;
         case 'author':
             $output = TablePress::get_user_display_name($table['author']);
             break;
         case 'number_rows':
             $output = count($table['data']);
             if ('raw' != $format) {
//.........这里部分代码省略.........
开发者ID:heyjones,项目名称:crossfitpurpose,代码行数:101,代码来源:controller-frontend.php


示例14: load_tablepress_in_the_admin

function load_tablepress_in_the_admin()
{
    if (is_admin() && defined('DOING_AJAX') && DOING_AJAX) {
        TablePress::load_controller('frontend');
        // работает на дефолтной теме
        // TablePress::$controller = TablePress::load_controller( 'admin_ajax' );
    }
}
开发者ID:jetfire21,项目名称:mod-box,代码行数:8,代码来源:functions.php


示例15: save_custom_css_to_file

 /**
  * Save "Custom CSS" to a file, or return HTML for the credentials form
  *
  * @since 1.0.0
  *
  * @return string (if necessary) HTML for the credentials form for the WP_Filesystem API
  */
 public function save_custom_css_to_file()
 {
     // Set current screen to get Screen Icon to have a custom HTML ID, so that we can hide it with CSS
     set_current_screen('tablepress_options_invisible');
     // Start capturing the output, to get HTML of the credentials form (if needed)
     ob_start();
     $url = '';
     // same page
     $credentials = request_filesystem_credentials($url, '', false, false, null);
     // do we have credentials already? (Otherwise the form will have been rendered already.)
     if (false === $credentials) {
         $form_data = ob_get_contents();
         ob_end_clean();
         $form_data = str_replace('name="upgrade" id="upgrade" class="button"', 'name="upgrade" id="upgrade" class="button button-primary button-large"', $form_data);
         return $form_data;
     }
     // we have received credentials, but don't know if they are valid yet
     if (!WP_Filesystem($credentials)) {
         // credentials failed, so ask again (with $error flag true)
         request_filesystem_credentials($url, '', true, false, null);
         $form_data = ob_get_contents();
         ob_end_clean();
         $form_data = str_replace('name="upgrade" id="upgrade" class="button"', 'name="upgrade" id="upgrade" class="button button-primary button-large"', $form_data);
         return $form_data;
     }
     // we have valid access to the filesystem now -> try to save the file
     $filename = WP_CONTENT_DIR . '/tablepress-custom.css';
     $filename = apply_filters('tablepress_custom_css_file_name', $filename);
     $filename_min = WP_CONTENT_DIR . '/tablepress-custom.min.css';
     $filename_min = apply_filters('tablepress_custom_css_minified_file_name', $filename_min);
     // Check if file name is valid (0 means yes)
     if (0 !== validate_file($filename) || 0 !== validate_file($filename_min)) {
         TablePress::redirect(array('action' => 'options', 'message' => 'success_save_error_custom_css'));
     }
     global $wp_filesystem;
     // WP_CONTENT_DIR and (FTP-)Content-Dir can be different (e.g. if FTP working dir is /)
     // We need to account for that by replacing the path difference in the filename
     $path_difference = str_replace($wp_filesystem->wp_content_dir(), '', trailingslashit(WP_CONTENT_DIR));
     if ('' != $path_difference) {
         $filename = str_replace($path_difference, '', $filename);
         $filename_min = str_replace($path_difference, '', $filename_min);
     }
     $custom_css = $this->get('custom_css');
     $custom_css_minified = $this->get('custom_css_minified');
     $result = $wp_filesystem->put_contents($filename, $custom_css, FS_CHMOD_FILE);
     $result_min = $wp_filesystem->put_contents($filename_min, $custom_css_minified, FS_CHMOD_FILE);
     if (!$result || !$result_min) {
         TablePress::redirect(array('action' => 'options', 'message' => 'success_save_error_custom_css'));
     }
     // at this point, saving was successful, so enable the checkbox again
     // (if it was not enabled before, we would never have tried to save)
     // and also increase the "Custom CSS" version number (for cache busting)
     $this->update(array('use_custom_css_file' => true, 'custom_css_version' => $this->get('custom_css_version') + 1));
     TablePress::redirect(array('action' => 'options', 'message' => 'success_save'));
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:62,代码来源:model-options.php


示例16: _search_callback

 /**
  * Callback to determine whether the given $item contains the search term.
  *
  * @since 1.0.0
  *
  * @param string $item Table ID that shall be searched.
  * @return bool Whether the search term was found or not.
  */
 protected function _search_callback($item)
 {
     static $term, $json_encoded_term;
     if (is_null($term) || is_null($json_encoded_term)) {
         $term = wp_unslash($_GET['s']);
         $json_encoded_term = substr(json_encode($term), 1, -1);
     }
     // Load table again, with table data, but without options and visibility settings.
     $item = TablePress::$model_table->load($item, true, false);
     if (isset($item['is_corrupted']) && $item['is_corrupted']) {
         return false;
         // Don't search corrupted tables
     }
     // Search from easy to hard, so that "expensive" code maybe doesn't have to run.
     if (false !== stripos($item['id'], $term) || false !== stripos($item['name'], $term) || false !== stripos($item['description'], $term) || false !== stripos(TablePress::get_user_display_name($item['author']), $term) || false !== stripos(TablePress::format_datetime($item['last_modified'], 'mysql', ' '), $term) || false !== stripos(json_encode($item['data']), $json_encoded_term)) {
         return true;
     }
     return false;
 }
开发者ID:RA2WP,项目名称:RA2WP,代码行数:27,代码来源:view-editor_button_thickbox.php


示例17: textbox_uninstall_tablepress

    /**
     * Print the content of the "Admin Options" post meta box.
     *
     * @since 1.0.0
     *
     * @param array $data Data for this screen.
     * @param array $box  Information about the text box.
     */
    public function textbox_uninstall_tablepress(array $data, array $box)
    {
        ?>
		<h1 style="margin-top:40px;"><?php 
        _e('Uninstall TablePress', 'tablepress');
        ?>
</h1>
		<p><?php 
        echo __('Uninstalling <strong>will permanently delete</strong> all TablePress tables and options from the database.', 'tablepress') . '<br />' . __('It is recommended that you create a backup of the tables (by exporting the tables in the JSON format), in case you later change your mind.', 'tablepress') . '<br />' . __('You will manually need to remove the plugin&#8217;s files from the plugin folder afterwards.', 'tablepress') . '<br />' . __('Be very careful with this and only click the button if you know what you are doing!', 'tablepress');
        ?>
</p>
		<p><a href="<?php 
        echo TablePress::url(array('action' => 'uninstall_tablepress'), true, 'admin-post.php');
        ?>
" id="uninstall-tablepress" class="button"><?php 
        _e('Uninstall TablePress', 'tablepress');
        ?>
</a></p>
		<?php 
    }
开发者ID:akumanu,项目名称:wordpress-gk,代码行数:28,代码来源:view-options.php


示例18: _prepare_render_data

 /**
  * Remove all cells from the data set that shall not be rendered, because they are hidden.
  *
  * @since 1.0.0
  */
 protected function _prepare_render_data()
 {
     $orig_table = $this->table;
     $num_rows = count($this->table['data']);
     $num_columns = $num_rows > 0 ? count($this->table['data'][0]) : 0;
     // Evaluate show/hide_rows/columns parameters.
     $actions = array('show', 'hide');
     $elements = array('rows', 'columns');
     foreach ($actions as $action) {
         foreach ($elements as $element) {
             if (empty($this->render_options["{$action}_{$element}"])) {
                 $this->render_options["{$action}_{$element}"] = array();
                 continue;
             }
             // Add all rows/columns to array if "all" value set for one of the four parameters.
             if ('all' === $this->render_options["{$action}_{$element}"]) {
                 $this->render_options["{$action}_{$element}"] = range(0, ${'num_' . $element} - 1);
                 continue;
             }
             // We have a list of rows/columns (possibly with ranges in it).
             $this->render_options["{$action}_{$element}"] = explode(',', $this->render_options["{$action}_{$element}"]);
             // Support for ranges like 3-6 or A-BA.
             $range_cells = array();
             foreach ($this->render_options["{$action}_{$element}"] as $key => $value) {
                 $range_dash = strpos($value, '-');
                 if (false !== $range_dash) {
                     unset($this->render_options["{$action}_{$element}"][$key]);
                     $start = substr($value, 0, $range_dash);
                     if (!is_numeric($start)) {
                         $start = TablePress::letter_to_number($start);
                     }
                     $end = substr($value, $range_dash + 1);
                     if (!is_numeric($end)) {
                         $end = TablePress::letter_to_number($end);
                     }
                     $current_range = range($start, $end);
                     $range_cells = array_merge($range_cells, $current_range);
                 }
             }
             $this->render_options["{$action}_{$element}"] = array_merge($this->render_options["{$action}_{$element}"], $range_cells);
             /*
              * Parse single letters and change from regular numbering to zero-based numbering,
              * as rows/columns are indexed from 0 internally, but from 1 externally
              */
             foreach ($this->render_options["{$action}_{$element}"] as $key => $value) {
                 if (!is_numeric($value)) {
                     $value = TablePress::letter_to_number($value);
                 }
                 $this->render_options["{$action}_{$element}"][$key] = (int) $value - 1;
             }
             // Remove duplicate entries and sort the array.
             $this->render_options["{$action}_{$element}"] = array_unique($this->render_options["{$action}_{$element}"]);
             sort($this->render_options["{$action}_{$element}"], SORT_NUMERIC);
         }
     }
     // Load information about hidden rows and columns.
     // Get indexes of hidden rows (array value of 0).
     $hidden_rows = array_keys($this->table['visibility']['rows'], 0);
     $hidden_rows = array_merge($hidden_rows, $this->render_options['hide_rows']);
     $hidden_rows = array_diff($hidden_rows, $this->render_options['show_rows']);
     // Get indexes of hidden columns (array value of 0).
     $hidden_columns = array_keys($this->table['visibility']['columns'], 0);
     $hidden_columns = array_merge($hidden_columns, $this->render_options['hide_columns']);
     $hidden_columns = array_merge(array_diff($hidden_columns, $this->render_options['show_columns']));
     // Remove hidden rows and re-index.
     foreach ($hidden_rows as $row_idx) {
         unset($this->table['data'][$row_idx]);
     }
     $this->table['data'] = array_merge($this->table['data']);
     // Remove hidden columns and re-index.
     foreach ($this->table['data'] as $row_idx => $row) {
         foreach ($hidden_columns as $col_idx) {
             unset($row[$col_idx]);
         }
         $this->table['data'][$row_idx] = array_merge($row);
     }
     /**
      * Filter the table after processing the table visibility information.
      *
      * @since 1.0.0
      *
      * @param array $table          The processed table.
      * @param array $orig_table     The unprocessed table.
      * @param array $render_options The render options for the table.
      */
     $this->table = apply_filters('tablepress_table_render_data', $this->table, $orig_table, $this->render_options);
 }
开发者ID:pab44,项目名称:pab44,代码行数:92,代码来源:class-render.php


示例19: handle_get_action_editor_button_thickbox

 /**
  * Show a list of tables in the Editor toolbar Thickbox (opened by TinyMCE or Quicktags button)
  *
  * @since 1.0.0
  */
 public function handle_get_action_editor_button_thickbox()
 {
     TablePress::check_nonce('editor_button_thickbox');
     $this->init_i18n_support();
     $view_data = array('tables' => $this->model_table->load_all());
     set_current_screen('tablepress_editor_button_thickbox');
     // Prepare, initialize, and render the view
     $this->view = TablePress::load_view('editor_button_thickbox', $view_data);
     $this->view->render();
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:15,代码来源:controller-admin.php


示例20: _order_callback

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Table_Frame_Decorator类代码示例发布时间:2022-05-23
下一篇:
PHP TableDiffFormatter类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap