From 085f63bbc063b2356c9b796e09ba107ca7f7967b Mon Sep 17 00:00:00 2001 From: Stefan van den Dungen Gronovius Date: Tue, 25 Aug 2020 11:50:00 +0200 Subject: [PATCH 1/3] WIP --- README.md | 20 ++++++++-------- ac-COLUMN_NAME.php => ac-CUSTOM_NAMESPACE.php | 18 +++++++-------- .../Free/COLUMN_NAME.php} | 8 +++---- .../Pro/COLUMN_NAME.php} | 23 ++++++++----------- .../{Editing.php => Editing/COLUMN_NAME.php} | 4 ++-- .../{Export.php => Export/COLUMN_NAME.php} | 4 ++-- .../COLUMN_NAME.php} | 4 ++-- .../COLUMN_NAME.php} | 4 ++-- .../{Sorting.php => Sorting/COLUMN_NAME.php} | 4 ++-- 9 files changed, 44 insertions(+), 45 deletions(-) rename ac-COLUMN_NAME.php => ac-CUSTOM_NAMESPACE.php (72%) rename classes/{ColumnFree.php => Column/Free/COLUMN_NAME.php} (96%) rename classes/{ColumnPro.php => Column/Pro/COLUMN_NAME.php} (68%) rename classes/{Editing.php => Editing/COLUMN_NAME.php} (93%) rename classes/{Export.php => Export/COLUMN_NAME.php} (81%) rename classes/{Filtering.php => Filtering/COLUMN_NAME.php} (92%) rename classes/{SmartFiltering.php => SmartFiltering/COLUMN_NAME.php} (93%) rename classes/{Sorting.php => Sorting/COLUMN_NAME.php} (90%) diff --git a/README.md b/README.md index 8b47486..c76734c 100755 --- a/README.md +++ b/README.md @@ -4,9 +4,10 @@ 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. +It can also be used to create multiple columns in this plugin since the directory structur is prepared to contains multiple column classes. ### Structure @@ -15,20 +16,21 @@ This template is for Admin Columns ánd Admin Columns Pro. * `/languages`: folder for .pot, .po and .mo files * `ac-COLUMN_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. This is used for text domain statements and the namespace declaration +* `CUSTOM_NAMESPACE`: Single word, no spaced. Underscrores allowed. This is used for text domain statements and the namespace declaration * `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 diff --git a/ac-COLUMN_NAME.php b/ac-CUSTOM_NAMESPACE.php similarity index 72% rename from ac-COLUMN_NAME.php rename to ac-CUSTOM_NAMESPACE.php index 2b43a7a..1193a58 100755 --- a/ac-COLUMN_NAME.php +++ b/ac-CUSTOM_NAMESPACE.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 @@ Date: Tue, 25 Aug 2020 13:07:57 +0200 Subject: [PATCH 2/3] Placeholder Checks --- README.md | 16 ++++++++++------ ac-CUSTOM_NAMESPACE.php => ac-PLUGIN_NAME.php | 0 .../{ac-COLUMN_NAME.po => ac-PLUGIN_NAME.po} | 0 readme.txt | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) rename ac-CUSTOM_NAMESPACE.php => ac-PLUGIN_NAME.php (100%) rename languages/{ac-COLUMN_NAME.po => ac-PLUGIN_NAME.po} (100%) diff --git a/README.md b/README.md index c76734c..44d491b 100755 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ For more information about creating a new field type, please read the following https://docs.admincolumns.com/article/21-how-to-create-my-own-column This template is for Admin Columns ánd Admin Columns Pro. -It can also be used to create multiple columns in this plugin since the directory structur is prepared to contains multiple column classes. ### Structure @@ -29,8 +28,8 @@ It can also be used to create multiple columns in this plugin since the director 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. This is used for text domain statements and the namespace declaration -* `CUSTOM_NAMESPACE`: Single word, no spaced. Underscrores allowed. This is used for text domain statements and the namespace declaration +* `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 @@ -42,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 @@ -66,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-CUSTOM_NAMESPACE.php b/ac-PLUGIN_NAME.php similarity index 100% rename from ac-CUSTOM_NAMESPACE.php rename to ac-PLUGIN_NAME.php diff --git a/languages/ac-COLUMN_NAME.po b/languages/ac-PLUGIN_NAME.po similarity index 100% rename from languages/ac-COLUMN_NAME.po rename to languages/ac-PLUGIN_NAME.po diff --git a/readme.txt b/readme.txt index 7a391d4..9ecb164 100755 --- a/readme.txt +++ b/readme.txt @@ -1,4 +1,4 @@ -=== Admin Columns - COLUMN_LABEL Column === +=== Admin Columns - COLUMN_PLUGIN === Contributors: AUTHOR_NAME Tags: PLUGIN_TAGS Requires at least: 3.5 @@ -15,7 +15,7 @@ EXTENDED_DESCRIPTION == Installation == -1. Copy the `ac-column-COLUMN_NAME` folder into your `wp-content/plugins` folder +1. Copy the `ac-PLUGIN_NAME` 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 From 033724534736bcd1a754503093ce67cc2354c6c6 Mon Sep 17 00:00:00 2001 From: Stefan van den Dungen Gronovius Date: Tue, 25 Aug 2020 13:09:09 +0200 Subject: [PATCH 3/3] Typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 44d491b..25f227e 100755 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ 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/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