diff --git a/README.md b/README.md index 8b47486..25f227e 100755 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Welcome to the Admin Columns column template repository. Here you will find a starter-kit for creating a new column for Admin Columns. This start-kit will work as a normal WP plugin. For more information about creating a new field type, please read the following article: -https://www.admincolumns.com/documentation/guides/creating-new-column-type/ +https://docs.admincolumns.com/article/21-how-to-create-my-own-column This template is for Admin Columns ánd Admin Columns Pro. @@ -13,22 +13,23 @@ This template is for Admin Columns ánd Admin Columns Pro. * `/css`: folder for .css files * `/js`: folder for .js files * `/languages`: folder for .pot, .po and .mo files -* `ac-COLUMN_NAME.php`: Main plugin file that registers the column +* `ac-PLUGIN_NAME.php`: Main plugin file that registers the column * `/classes`: folder containing the separate logic classes -* `/classes/ColumnFree.php`: Column class with all column logic for the free version -* `/classes/ColumnPro.php`: Column class with all column logic for the pro version -* `/classes/Editing.php`: Editing Model with all editing related logic -* `/classes/Filtering.php`: Filtering Model with all filtering related logic -* `/classes/Export.php`: Simple Export Model loaded through the Pro column -* `/classes/Filtering.php`: Example Filtering Model loaded through Pro column -* `/classes/SmartFiltering.php`: Example Smart Filtering Comparison (Model) loaded through Pro column -* `/classes/Sorting.php`: Simple Sorting Model loaded through Pro column +* `/classes/Column/Free/COLUMN_NAME.php`: Column class with all column logic for the free version +* `/classes/Column/Pro/COLUMN_NAME.php`: Column class with all column logic for the pro version +* `/classes/Editing/COLUMN_NAME.php`: Editing Model with all editing related logic +* `/classes/Export/COLUMN_NAME.php`: Simple Export Model loaded through the Pro column +* `/classes/Filtering/COLUMN_NAME.php`: Example Filtering Model loaded through Pro column +* `/classes/SmartFiltering/COLUMN_NAME.php`: Example Smart Filtering Comparison (Model) loaded through Pro column +* `/classes/Sorting/COLUMN_NAME.php`: Simple Sorting Model loaded through Pro column * `readme.txt`: WordPress readme file to be used by the wordpress repository ### step 1. This template uses `PLACEHOLDERS` such as `COLUMN_NAME` throughout the file names and code. Use the following list of placeholders to do a 'find and replace': +* `PLUGIN_NAME`: Single word, no spaced. Underscrores allowed. Used for the text-domain and plugin description. +* `CUSTOM_NAMESPACE`: Single word, no spaced. Underscrores allowed. Used for the namespace declarations in the different class files. * `COLUMN_NAME`: Single word, no spaces. Underscores allowed. eg. donate_button * `COLUMN_LABEL`: Multiple words, can include spaces, visible when selecting a column * `PLUGIN_URL`: Url to the github or WordPress repository @@ -40,16 +41,21 @@ This template uses `PLACEHOLDERS` such as `COLUMN_NAME` throughout the file name ### step 2. -Edit the `ac-COLUMN_NAME.php` file (now renamed using your column name) and change the column type if necessary. +Edit the `ac-PLUGIN_NAME.php` file (now renamed using your plugin name) and change the column type if necessary. ### step 3. -Edit the `ac-column-COLUMN_NAME.php` file (now renamed using your column name) and include your custom code in the appropriate functions. +Edit the `COLUMN_NAME.php` files (now renamed using your column name) and include your custom code in the appropriate functions. ### step 4. Edit this `README.md` file with the appropriate information and delete all content above and including the following line. +### step 5 (optional). + +The structure of this plugin is prepared so that it can contain multiple columns. +If you want to create multiple custom columns in this plugin, you can create a copy of each of the files and use a different name for your files that represents the column classes. + ----------------------- # Admin Columns COLUMN_LABEL Column @@ -64,7 +70,7 @@ EXTENDED_DESCRIPTION ### Installation -1. Copy the `ac-column-COLUMN_NAME` folder into your `wp-content/plugins` folder +1. Copy the `ac-column-template` folder into your `wp-content/plugins` folder 2. Activate the COLUMN_LABEL plugin via the plugins admin page 3. Create a new column via Admin Columns and select the COLUMN_LABEL column 4. Please refer to the description for more info regarding the field type settings diff --git a/ac-COLUMN_NAME.php b/ac-PLUGIN_NAME.php similarity index 72% rename from ac-COLUMN_NAME.php rename to ac-PLUGIN_NAME.php index 2b43a7a..1193a58 100755 --- a/ac-COLUMN_NAME.php +++ b/ac-PLUGIN_NAME.php @@ -1,6 +1,6 @@ register_prefix( 'AC\Custom\COLUMN_NAME', __DIR__ . '/classes/' ); + \AC\Autoloader::instance()->register_prefix( 'CUSTOM_NAMESPACE', __DIR__ . '/classes/' ); add_action( 'ac/column_types', function ( \AC\ListScreen $list_screen ) { @@ -27,30 +27,30 @@ // Register column // Register a column WITHOUT pro features - // $list_screen->register_column_type( new \AC\Custom\COLUMN_NAME\ColumnFree() ); + //$list_screen->register_column_type( new \CUSTOM_NAMESPACE\Column\Free\COLUMN_NAME() ); // Register a column WITH pro features - $list_screen->register_column_type( new \AC\Custom\COLUMN_NAME\ColumnPro() ); + $list_screen->register_column_type( new \CUSTOM_NAMESPACE\Column\Pro\COLUMN_NAME() ); } // Example #2 - for media // if ( 'attachment' === $list_screen->get_key() ) { - // Register column + // Register column // } // Example #3 - for all post types // if ( \AC\MetaType::POST === $list_screen->get_meta_type() ) { - // Register column + // Register column // } // Example #4 - for users // if ( \AC\MetaType::USER === $list_screen->get_meta_type() ) { - // Register column + // Register column // } // Example #4 - for categories on the taxonomy list table // if ( $list_screen instanceof \ACP\ListScreen\Taxonomy && 'category' === $list_screen->get_taxonomy()) { - // Register column + // Register column // } } ); diff --git a/classes/ColumnFree.php b/classes/Column/Free/COLUMN_NAME.php similarity index 96% rename from classes/ColumnFree.php rename to classes/Column/Free/COLUMN_NAME.php index cb7e6d6..af87db6 100755 --- a/classes/ColumnFree.php +++ b/classes/Column/Free/COLUMN_NAME.php @@ -1,8 +1,8 @@