- Timestamp:
- 04/06/2023 04:00:27 PM (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
simple-csv-tables/trunk/admin/class-simple-csv-tables-admin.php
r2287385 r2895145 1 1 <?php 2 2 3 use Carbon_Fields\Container; 3 4 use Carbon_Fields\Field; … … 23 24 * @author Sirvelia <info@sirvelia.com> 24 25 */ 25 class Simple_CSV_Tables_Admin { 26 class Simple_CSV_Tables_Admin 27 { 26 28 27 29 /** … … 50 52 * @param string $version The version of this plugin. 51 53 */ 52 public function __construct( $plugin_name, $version ) { 54 public function __construct($plugin_name, $version) 55 { 53 56 54 57 $this->plugin_name = $plugin_name; 55 58 $this->version = $version; 56 57 59 } 58 59 /**60 * Register the stylesheets for the admin area.61 *62 * @since 1.0.063 */64 public function enqueue_styles() {65 66 //wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/simple-csv-tables-admin.css', array(), $this->version, 'all' );67 68 }69 70 /**71 * Register the JavaScript for the admin area.72 *73 * @since 1.0.074 */75 public function enqueue_scripts() {76 77 //wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/simple-csv-tables-admin.js', array( 'jquery' ), $this->version, false );78 79 }80 81 60 82 61 /** … … 85 64 * @since 1.0.0 86 65 */ 87 public function create_csv_table_cpt() { 66 public function create_csv_table_cpt() 67 { 88 68 89 69 $labels = array( 90 'name' => _x( 'CSV tables', 'Post Type General Name', 'simple-csv-tables'),91 'singular_name' => _x( 'CSV table', 'Post Type Singular Name', 'simple-csv-tables'),70 'name' => _x(), 71 'singular_name' => _x(), 92 72 ); 93 73 $args = array( 94 'label' => __( 'CSV table', 'simple-csv-tables'),74 'label' => __(), 95 75 'labels' => $labels, 96 'supports' => array( 'title'),76 'supports' => array(), 97 77 'hierarchical' => false, 98 78 'public' => false, … … 109 89 'capability_type' => 'post', 110 90 ); 111 register_post_type( 'csv-table', $args); 112 91 register_post_type('csv-table', $args); 113 92 } 114 93 … … 118 97 * @since 1.0.0 119 98 */ 120 public function load_vendor() { 99 public function load_vendor() 100 { 121 101 require_once SIMPLE_CSV_TABLES_PATH . 'vendor/autoload.php'; 122 102 \Carbon_Fields\Carbon_Fields::boot(); 123 103 } 124 104 … … 128 108 * @since 1.0.0 129 109 */ 130 public function create_fields() { 110 public function create_fields() 111 { 131 112 132 Container::make( 'post_meta', __( 'Import file', 'simple-csv-tables' ) ) 133 ->where( 'post_type', '=', 'csv-table' ) 134 ->add_fields( array( 135 Field::make( 'file', 'csv_file', __( 'CSV file', 'simple-csv-tables' ) ) 136 ->set_type( array( 'text/csv' ) ) 137 ->set_width( 33 ), 138 Field::make( 'text', 'csv_delimiter', __( 'CSV delimiter', 'simple-csv-tables' ) ) 139 ->set_default_value( ',' ) 140 ->set_width( 33 ), 141 Field::make( 'html', 'csv_shortcode', __( 'Shortcode', 'simple-csv-tables' ) ) 142 ->set_html( array($this, 'show_shortcode') ) 143 ->set_width( 34 ) 144 ) ); 145 113 Container::make('post_meta', __('Import file', 'simple-csv-tables')) 114 ->where('post_type', '=', 'csv-table') 115 ->add_fields(array( 116 Field::make('file', 'csv_file', __('CSV file', 'simple-csv-tables')) 117 ->set_type(array('text/csv')) 118 ->set_width(33), 119 Field::make('text', 'csv_delimiter', __('CSV delimiter', 'simple-csv-tables')) 120 ->set_default_value(',') 121 ->set_width(33), 122 Field::make('html', 'csv_shortcode', __('Shortcode', 'simple-csv-tables')) 123 ->set_html(array($this, 'show_shortcode')) 124 ->set_width(34) 125 )); 146 126 } 147 127 … … 151 131 * @since 1.0.0 152 132 */ 153 function show_shortcode() { 133 function show_shortcode() 134 { 154 135 155 if ( isset($_GET['post']) ):156 $post_id = intval( $_GET['post']);157 if ( is_int($post_id) ):136 if: 137 ); 138 if: 158 139 return ' 159 140 <div class="cf-field__head"> 160 141 <label class="cf-field__label" style="display: block"> 161 ' . __( 'Shortcode', 'simple-csv-tables' ) .'142 '' 162 143 </label> 163 </div><p>[show_csv_table id=' . $post_id . ']</p>';144 </div><p>[show_csv_table id=' . $post_id .']</p>'; 164 145 endif; 165 146 endif; 166 147 167 148 return ''; 168 169 149 } 170 150 … … 174 154 * @since 1.0.0 175 155 */ 176 public function set_csv_admin_columns($columns) { 177 $columns['csv_shortcode'] = __( 'Shortcode', 'simple-csv-tables' ); 178 return $columns; 156 public function set_csv_admin_columns($columns) 157 { 158 $columns['csv_shortcode'] = __('Shortcode', 'simple-csv-tables'); 159 return $columns; 179 160 } 180 161 … … 184 165 * @since 1.0.0 185 166 */ 186 public function add_csv_admin_columns_data($column, $post_id) { 167 public function add_csv_admin_columns_data($column, $post_id) 168 { 187 169 188 switch ( $column ) { 189 case 'csv_shortcode' : 190 echo '[show_csv_table id=' . $post_id .']'; 191 break; 192 } 193 170 switch ($column) { 171 case 'csv_shortcode': 172 echo '[show_csv_table id=' . $post_id . ']'; 173 break; 174 } 194 175 } 195 196 176 }
Note: See TracChangeset
for help on using the changeset viewer.