Plugin Directory

Timestamp:
04/06/2023 04:00:27 PM (16 months ago)
Author:
joanrodas
Message:

Version 1.0.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • simple-csv-tables/trunk/admin/class-simple-csv-tables-admin.php

    r2287385 r2895145  
    11<?php
     2
    23use Carbon_Fields\Container;
    34use Carbon_Fields\Field;
     
    2324 * @author     Sirvelia <info@sirvelia.com>
    2425 */
    25 class Simple_CSV_Tables_Admin {
     26class Simple_CSV_Tables_Admin
     27{
    2628
    2729    /**
     
    5052     * @param      string    $version    The version of this plugin.
    5153     */
    52     public function __construct( $plugin_name, $version ) {
     54    public function __construct($plugin_name, $version)
     55    {
    5356
    5457        $this->plugin_name = $plugin_name;
    5558        $this->version = $version;
    56 
    5759    }
    58 
    59     /**
    60      * Register the stylesheets for the admin area.
    61      *
    62      * @since    1.0.0
    63      */
    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.0
    74      */
    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 
    8160
    8261    /**
     
    8564     * @since    1.0.0
    8665     */
    87     public function create_csv_table_cpt() {
     66    public function create_csv_table_cpt()
     67    {
    8868
    8969        $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(),
    9272        );
    9373        $args = array(
    94             'label'                 => __( 'CSV table', 'simple-csv-tables' ),
     74            'label'                 => __(),
    9575            'labels'                => $labels,
    96             'supports'              => array( 'title' ),
     76            'supports'              => array(),
    9777            'hierarchical'          => false,
    9878            'public'                => false,
     
    10989            'capability_type'       => 'post',
    11090        );
    111         register_post_type( 'csv-table', $args);
    112 
     91        register_post_type('csv-table', $args);
    11392    }
    11493
     
    11897     * @since    1.0.0
    11998     */
    120     public function load_vendor() {
     99    public function load_vendor()
     100    {
    121101        require_once SIMPLE_CSV_TABLES_PATH . 'vendor/autoload.php';
    122     \Carbon_Fields\Carbon_Fields::boot();
     102\Carbon_Fields\Carbon_Fields::boot();
    123103    }
    124104
     
    128108     * @since    1.0.0
    129109     */
    130     public function create_fields() {
     110    public function create_fields()
     111    {
    131112
    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            ));
    146126    }
    147127
     
    151131     * @since    1.0.0
    152132     */
    153     function show_shortcode() {
     133    function show_shortcode()
     134    {
    154135
    155         if( isset($_GET['post']) ):
    156         $post_id = intval( $_GET['post'] );
    157             if( is_int($post_id) ):
     136        if:
     137    );
     138            if:
    158139                return '
    159140            <div class="cf-field__head">
    160141              <label class="cf-field__label" style="display: block">
    161                 '. __( 'Shortcode', 'simple-csv-tables' ) .'
     142                ''
    162143              </label>
    163             </div><p>[show_csv_table id=' . $post_id .']</p>';
     144            </div><p>[show_csv_table id=' . $post_id .']</p>';
    164145            endif;
    165146        endif;
    166147
    167148        return '';
    168 
    169149    }
    170150
     
    174154     * @since    1.0.0
    175155     */
    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;
    179160    }
    180161
     
    184165     * @since    1.0.0
    185166     */
    186     public function add_csv_admin_columns_data($column, $post_id) {
     167    public function add_csv_admin_columns_data($column, $post_id)
     168    {
    187169
    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        }
    194175    }
    195 
    196176}
Note: See TracChangeset for help on using the changeset viewer.