PluginProbe ʕ •ᴥ•ʔ
Permalink Manager Lite / 2.5.1.2
Permalink Manager Lite v2.5.1.2
2.5.4 2.5.3.4 2.2.18 2.2.19.2 2.2.19.3 2.2.19.3.1 2.2.2 2.2.20 2.2.20.1 2.2.20.3 2.2.4 2.2.5 2.2.6 2.2.7.2 2.2.7.3 2.2.7.5 2.2.7.6 2.2.8.4 2.2.8.5 2.2.8.6 2.2.8.7 2.2.8.9 2.2.9.1 2.2.9.2 2.2.9.2.1 2.2.9.3 2.2.9.4 2.2.9.6 2.2.9.7 2.2.9.9 2.3.0 2.3.1.1 2.4.0 2.4.1 2.4.1.2 2.4.1.3 2.4.1.4 2.4.1.5 2.4.1.6 2.4.2 2.4.2.1 2.4.3 2.4.3.1 2.4.3.2 2.4.3.3 2.4.3.4 2.4.4 2.4.4.1 2.4.4.2 2.4.4.3 2.5.0 2.5.1 2.5.1.1 2.5.1.2 2.5.1.3 2.5.1.4 2.5.2 2.5.2.1 2.5.2.2 2.5.2.3 2.5.2.4 2.5.3 2.5.3.1 2.5.3.2 2.5.3.3 trunk 0.2 0.3 0.3.1 0.3.2 0.3.3 0.3.4 0.4 0.4.1 0.4.2 0.4.3 0.4.4 0.4.6 0.4.7 0.4.8 0.4.9 0.5.3 0.5.4 1.0.0 1.0.1 1.0.4 1.1.0 1.1.1 1.1.2 1.11.6.3 2.0.0 2.0.3 2.0.4 2.0.4.3 2.0.5.1 2.0.5.2 2.0.5.3 2.0.5.3.1 2.0.5.4 2.0.5.4a 2.0.5.5 2.0.5.6 2.0.5.6.1 2.0.5.7 2.0.5.9a 2.0.6.2.1 2.0.6.2a 2.0.6.3 2.1.0 2.1.1 2.1.2.4 2.2.0 2.2.1.1 2.2.1.2 2.2.11 2.2.12 2.2.13.1 2.2.14 2.2.15.1 2.2.16 2.2.17
permalink-manager / includes / views / permalink-manager-uri-editor.php
permalink-manager / includes / views Last commit date
permalink-manager-debug.php 1 year ago permalink-manager-permastructures.php 1 year ago permalink-manager-settings.php 1 year ago permalink-manager-tools.php 1 year ago permalink-manager-ui-elements.php 1 year ago permalink-manager-uri-editor-post.php 1 year ago permalink-manager-uri-editor.php 1 year ago
permalink-manager-uri-editor.php
155 lines
1 <?php
2
3 /**
4 * Display Bulk URI Editor
5 */
6 class Permalink_Manager_URI_Editor {
7 public $this_section = 'uri_editor';
8
9 public function __construct() {
10 add_filter( 'permalink_manager_sections', array( $this, 'add_admin_section' ), 0 );
11 add_filter( 'screen_settings', array( $this, 'screen_options' ), 99, 2 );
12 }
13
14 /**
15 * Add a new section to the Permalink Manager UI
16 *
17 * @param array $admin_sections
18 *
19 * @return array
20 */
21 public function add_admin_section( $admin_sections ) {
22 $admin_sections[ $this->this_section ] = array(
23 'name' => __( 'URI Editor', 'permalink-manager' )
24 );
25
26 // Display separate section for each post type
27 $post_types = Permalink_Manager_Helper_Functions::get_post_types_array( 'full' );
28 foreach ( $post_types as $post_type_name => $post_type ) {
29 // Check if post type exists
30 if ( ! post_type_exists( $post_type_name ) ) {
31 continue;
32 }
33
34 $icon = ( class_exists( 'WooCommerce' ) && $post_type_name == 'product' ) ? "<i class=\"woocommerce-icon woocommerce-cart\"></i>" : "";
35
36 $admin_sections[ $this->this_section ]['subsections'][ $post_type_name ] = array(
37 'name' => "{$icon} {$post_type['label']}",
38 'function' => array( 'class' => 'Permalink_Manager_URI_Editor_Post', 'method' => 'display_admin_section' )
39 );
40 }
41
42 // Permalink Manager Pro: Display separate section for each taxonomy
43 $taxonomies = Permalink_Manager_Helper_Functions::get_taxonomies_array( 'full' );
44 foreach ( $taxonomies as $taxonomy_name => $taxonomy ) {
45 // Check if taxonomy exists
46 if ( ! taxonomy_exists( $taxonomy_name ) ) {
47 continue;
48 }
49
50 // Get the icon
51 $icon = ( class_exists( 'WooCommerce' ) && in_array( $taxonomy_name, array( 'product_tag', 'product_cat' ) ) ) ? "<i class=\"woocommerce-icon woocommerce-cart\"></i>" : "<i class=\"dashicons dashicons-tag\"></i>";
52
53 $admin_sections[ $this->this_section ]['subsections']["tax_{$taxonomy_name}"] = array(
54 'name' => "{$icon} {$taxonomy['label']}",
55 'html' => Permalink_Manager_UI_Elements::pro_text(),
56 'pro' => true
57 );
58 }
59
60 // A little dirty hack to move wooCommerce product & taxonomies to the end of array
61 if ( class_exists( 'WooCommerce' ) ) {
62 foreach ( array( 'product', 'tax_product_tag', 'tax_product_cat' ) as $section_name ) {
63 if ( empty( $admin_sections[ $this->this_section ]['subsections'][ $section_name ] ) ) {
64 continue;
65 }
66 $section = $admin_sections[ $this->this_section ]['subsections'][ $section_name ];
67 unset( $admin_sections[ $this->this_section ]['subsections'][ $section_name ] );
68 $admin_sections[ $this->this_section ]['subsections'][ $section_name ] = $section;
69 }
70 }
71
72 return $admin_sections;
73 }
74
75 /**
76 * Display "Screen options"
77 *
78 * @param string $html
79 * @param string $screen
80 *
81 * @return string
82 */
83 public function screen_options( $html, $screen ) {
84 global $active_section;
85
86 // Display the screen options only in "Permalink Editor"
87 if ( $active_section != $this->this_section ) {
88 return $html;
89 }
90
91 $button = get_submit_button( __( 'Apply', 'permalink-manager' ), 'primary', 'screen-options-apply', false );
92 $html = "<fieldset class=\"permalink-manager-screen-options\">";
93
94 $screen_options = array(
95 'per_page' => array(
96 'type' => 'number',
97 'label' => __( 'Per page', 'permalink-manager' ),
98 'input_class' => 'settings-select'
99 ),
100 'post_statuses' => array(
101 'type' => 'checkbox',
102 'label' => __( 'Post statuses', 'permalink-manager' ),
103 'choices' => Permalink_Manager_Helper_Functions::get_post_statuses(),
104 'select_all' => '',
105 'unselect_all' => '',
106 )
107 );
108
109 foreach ( $screen_options as $field_name => $field_args ) {
110 $field_args['container'] = 'screen-options';
111 $html .= Permalink_Manager_UI_Elements::generate_option_field( "screen-options[{$field_name}]", $field_args );
112 }
113
114 $html .= sprintf( "</fieldset>%s", $button );
115
116 return $html;
117 }
118
119 /**
120 * Trigger SQL query to get all items
121 *
122 * @param $sql_parts
123 * @param $current_page
124 * @param $is_taxonomy
125 *
126 * @return array
127 */
128 public static function prepare_sql_query( $sql_parts, $current_page, $is_taxonomy = false ) {
129 global $permalink_manager_options, $wpdb;
130
131 $per_page = is_numeric( $permalink_manager_options['screen-options']['per_page'] ) ? $permalink_manager_options['screen-options']['per_page'] : 10;
132 $offset = ( $current_page - 1 ) * $per_page;
133
134 // Prepare the count SQL query
135 $count_query_parts = $sql_parts;
136 $count_query_parts['start'] = preg_replace( '/(SELECT.*FROM)/', 'SELECT COUNT(*) FROM', $count_query_parts['start'] );
137 $count_query = apply_filters( 'permalink_manager_filter_uri_editor_query', implode( "", $count_query_parts ), $count_query_parts, $is_taxonomy );
138 $total_items_raw = $wpdb->get_var( $count_query );
139
140 // Pagination support
141 $sql_query = implode( "", $sql_parts );
142 $sql_query .= sprintf( " LIMIT %d, %d", $offset, $per_page );
143
144 // Get items
145 $sql_query = apply_filters( 'permalink_manager_filter_uri_editor_query', $sql_query, $sql_parts, $is_taxonomy );
146 $all_items_raw = $wpdb->get_results( $sql_query, ARRAY_A );
147
148 $total_items = ( is_numeric( $total_items_raw ) ) ? (int) $total_items_raw : 0;
149 $all_items = ( ! empty( $all_items_raw ) ) ? $all_items_raw : array();
150
151 return array( $all_items, $total_items, $per_page );
152 }
153
154 }
155