diff --git a/.gitignore b/.gitignore index 5ebd21a..d5a9b33 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ +################# +## CUSTOM +################# + +*.bk* + ################# ## Eclipse ################# diff --git a/CHANGELOG.md b/CHANGELOG.md index fb79b30..a77bb56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,79 @@ == Changelog == += 0.4.0 = +* Added APL_Post_List Class for post data database structure with presets. +* Added APL_Design Class for post data database structure with preset designs; before, content, after, & empty message. +* Changed Preset data to use post data database structure (APL_Post_List & APL_Design). +* Added Admin Singleton Class. +* Changed to Custom Admin Menu. +* Added New Admin templates and multiple UI changes. +* Changed Info/Help to Tooltips instead of Dialogs. +* Added Post_Type filter by 'Any'. +* Changed 'Require Taxonomy' to 'Require Taxonomies' as a Post Type based filter instead. +* Added Sort by 'None' and 'Slug'. +* Added Post Status filter by 'None' and 'Any'. +* Added Perms filter by 'None'. +* Added Offset filter. +* Added additional Notice to front-end if attribute 'name' in [post_list] is invalid or missing. +* Added Sanitazion to shortcode attribute 'name'; ex. [post_list name=""]. +* Fixed Link attribute in post_category & post_tags shortcode. +* Added additional checks with php_function shortcode. +* Changed General Settings to Settings API w/ Meta Boxes. +* Added Ignore Post Types on Admin Post List screen. +* Changed/Fixed Exporting and Importing. +* Fixed possible defect with Plugin Options not being initiated. +* Added jQuery (UI) compatability. +* Removed jQuery UI Theme setting from APL Options. +* Changed Updater Class param items to update to an array. +* Changed version check to a hook method. +* Added WPML Support. +* Added Internalization for translations. +* Added non-class Functions file for common functions. +* Added hooks.php file to store custom hook examples. + += 0.3.7 = +* Fixed warning with load_plugin_textdomain. + += 0.3.6 = +* Added load_plugin_textdomain and .pot files. + += 0.3.5 = +* Fixed [post_excerpt] breaking last word. +* Fixed [post_excerpt length=""] not trimming if post excerpt is found. +* Fixed [php_function] Undefined Constant with KALIN_ALLOW_PHP when APL_ALLOW_PHP is defined. +* Added [post_title length=""] attribute. + += 0.3.4 = +* Fixed [final_end] not updating output string. + += 0.3.3 = +* Fixed [final_end] missing a param. +* Fixed Undefined index: post__not_in. +* Added initial Localization to prep support for multiple languages. + += 0.3.2 = +* Changed Internal Shortcodes to a Class Object as a Shortcode API. +* Changed support to Internal Shortcode to allow Attributes to be added in any order. +* Added attributes aliases user_name & user_description for the Labels attribute in [post_author]. +* Removed attribute labels that no longer exist in WP for the Labels attribute in [post_author]. +* Added custom max size support for the Size attribute in [post_thumb]. +* Fixed extract to correctly grab img tags for the Extract attribute in [post_thumb]. +* Fixed encoding when creating an excerpt from post/page content in [post_excerpt]. +* Added [post_type] shortcode, and label attribute. +* Added error check in [item_number]. +* Added check if other plugin is active in [post_pdf]. +* Added APL_ALLOW_PHP constant as a required varible for [php_function]. +* Removed APLCallback Class Object file. +* Changed Dialog location for Internal Shortcode to a seperate file. +* Added more encapsulation to initializing other class files. + += 0.3.1 = +* Added Assets. +* Added Icon to Assets. +* Changed Screenshots directory to Assets folder. +* Updated jQuery MultiSelect UI Widget files version 1.14 to 1.16. +* Fixed [post_terms] grabbing a wrong param. + = 0.3.0 = 08/29/2016 * Fixed error 'Un-Defined Variables and Non-Objects' with Excluding Duplicates. * Fixed List Amount '-1' Returning Nothing. diff --git a/README.md b/README.md index b4fcdd5..9c2fb3b 100644 --- a/README.md +++ b/README.md @@ -1,98 +1,80 @@ -=== Advanced Post List === -Contributors: EkoJr -Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=2E6Z4VQ6NF4CQ&lc=US&item_name=Wordpress%20%2d%20Advanced%20Post%20List¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted -Tags: Advanced, Post List, Categories, Category, Children, Children Pages, Content, Custom, Custom Post Type, Custom Post Types, Custom Taxonomy, Custom Taxonomies, Draft, Draft Posts, Excerpt, Filter, Future, Future Posts, Links, List, Links, News, Page, Pages, Parent, Parent Pages, Popular Posts, Post, Posts, Private, Private Posts, Related, Related Posts, Recent, Recent Posts, Shortcode, Shortcodes, Simple, Tag, Tags, Thumbnail, Widget, Widgets -Requires at least: 2.0.2 -Tested up to: 4.6 -Stable tag: 0.3.0 -License: GPLv2 or later -License URI: https://www.gnu.org/licenses/gpl-2.0.html - -Create custom post lists to display various content. Easy to use Filter & Design -as well as highly configurable and extensive. +Post List builder with highly customizable filter & custom designs. Whether it's displaying Recent Posts, Related Posts, Dynamic Posts, or a list of posts in general. == Description == -[wordpress forum]: https://wordpress.org/support/plugin/advanced-post-list - "Default WordPress Support" -[wordpress kalins post list]: http://wordpress.org/extend/plugins/kalins-post-list/ - "Kalin's Plugin" -[github issues]: https://github.com/EkoJr/wp-advanced-post-list/issues - "Ticket Handling" -[github wiki]: https://github.com/EkoJr/wp-advanced-post-list/wiki - "Contribute or Learn about APL" - -Highly customizable plugin for designing a large variety of post lists. Allowing -the Webmaster to create any design for displaying Recent Posts, Related Posts, -Future Posts, etc., and easily positioning it with a shortcode inside a Page or Post. -All that is required is you know HTML, but the plugin can also use CSS, -JavaScript, and PHP. - -Version 0.3 post query was switch to WP_Query to take advantage of the Custom Post -Types and Taxonomies featured within WordPress, and also has additional filter settings -added to further reach alternate methods of displaying posts. - -APL's Documentation/Wiki is located on [GitHub Wiki][github wiki]. - -Discovered a bug or an enhancement? Please submit thread/ticket at -[WordPress][wordpress forum] or [GitHub Issue Tickets][github issues]. - -When designing site with better navigation. This plugin accomplishes 3 main -tasks when displaying the site’s content through various lists. - -**Content of the post list** - -* **Custom Post Type and Taxonomy Support** – New addition adds the ability to -add even more posts and/or pages to your lists. Display any page from any -post type and has even more filter options with any additional taxonomies that -have been added. -* **Add/Require Any Number of Terms** – Create diverse post lists through any -configuration of terms within different taxonomies, and show any posts/pages -that has one related term, but if needed, post lists can be required to have -all terms selected. -* **Show Page Children** – Once only able to display one page’s children pages -from one hierarchical post type (WP built-in Pages). This plugin can now display -multitude of children pages from multiple pages from multiple hierarchical -post types. Making it easy to display sub-pages -* **Dynamically Add Terms and Page Parent** – Sometimes pages are expected to -change, and some area’s like the header, footer, and any sidebars are expected -to change. So it’s just plain simple and nice to have one configuration that -changes according to the visitor’s/user’s current page/post. -* **Show Content from Private, Future, Published, and More** – A new addition -added to show posts/page from not only publicly published posts/pages, but from -any status. Opening up the ability for creating private sections on a website -for users. - -**Style of the post list** - -* **Customizable Loop** – Any plugin of this design has to have a loop of some -kind to list the posts and/or pages. Most have their own style of design, but -this plugin gives the webmaster the tools to create his own style. -* **Shortcodes for Post/Page Content** – Part of the heart of the Customizable -Loop, shortcodes have made it possible to pull content from each post/page and -add it to the post list. - -**Location of the post list** - -* **Post List Shortcode** – User friendly method of adding any post list to a -section of a site. -* **PHP Hardcode** – Add post lists where some situations require a more -technical use where WordPress features and functions aren’t fully present. -* **Sidebar Widget (Coming soon)** – Originally was removed until 0.3 was -developed. Shortcodes have made it easy to add post lists to a text sidebar, -but there’s still plans to take full advantage of implementing the widget class. - - -This is an alternate version of [Kalins Post List][wordpress kalins post list] -which was unfortunately declared abandoned. Most of the credit for creating an -extraordinary plugin like this goes to Kalin. Currently, the plugin is still in -the first stages of its target design. Version 1.0.0 will feature many of the -functionalities that Kalin and others have mentioned, and will have a completely -new layout to accommodate for the extra tools that will be added. - - -**Pre-Release Projects for Version 1.0.0** - -* **(Completed)** Import/export - Export is broken until 0.3 stable (including importing data from Kalins Post List) -* **(Completed)** Custom Post Type & Taxonomies Support. Available in the 0.3 release. -* Additional sort methods for 'Orderby' combo box. -* Additional shortcodes. \ No newline at end of file +[apl getting started]: https://support.advancedpostlist.com/getting-started/ + "Getting Started w/ APL" +[apl qa]: https://support.advancedpostlist.com/qa/ + "Questions & Answers" +[apl docs]: https://support.advancedpostlist.com/documentation/ + "APL Documentation" +[apl shortcodes]: https://support.advancedpostlist.com/doc/internal-shortcodes/ + "List of Internal Shortcodes" +[wp apl support]: https://wordpress.org/support/plugin/advanced-post-list + "WordPress.org - Support for APL" +[github issues]: https://github.com/Advanced-Post-List/advanced-post-list/issues + "Report an Issue" +[github wiki]: https://github.com/Advanced-Post-List/advanced-post-list/wiki + "Learn or Contribute to APL" + +This tool functions much like a Post List builder to give Admins the most amount of control over managing content to display. Developed with Web Designers & Developers in mind, makes this a highly customizable tool to have around. However, there is a sharp learning curve for most. + +You must know: + +* HTML +* CSS +* _(Optional)_ + * JavaScript + * PHP + +## Summary + +Advanced Post List (aka APL) is designed to operate much like The Loop in WordPress; which is most notable in Themes. However, that concept is taken and turned into an Admin tool that can easily be changed, moved, or added/removed. This eliminates much of the backend work, and prevents being limited to what is hardcoded into a theme. + +This also makes multiple Featured Content with different configurations more of a breeze, and the complexity of it is a challenge that APL achieves unlike any other. + +APL can accomplish a large degree of variations, but can be broken down to 3 main types of tasks. With Filter, Design, and Placement, here are some of the key features. + +### Filter + +* **Custom Post Type and Taxonomy Support (CPT)** - Displays Posts/Pages from custom post types, taxonomies, and terms. This includes other plugins with post data. but may store its data differently than post_content. (**Advanced Users, see php_function shortcode.**) +* **Enhanced/Diverse Queries** - Capable of diverse filter configuration when displaying posts. This feature allows... + * Cross Filtering with Custom Post Types. + * Diverse Post Types -> Taxonomies query configurations. + * Multiple Query configurations with include and require. +* **Optimized with Complex Queries** - Once deemed an Achilles Heel to WP Query, steps are taken to reduce the server load as much as possible. +* **Dynamic Filters** - Grabs values to filter by based on the current posts/pages being viewed. _Ex. Displaying Related Posts in a Header, Footer, Sidebar, etc.._ +* **Show Content from Published, Private, Future, etc.** - This is a *development feature* and may not provide intended results. Display content on the frontend so users don’t have to navigate to the admin side. Allowing private landing pages to be created. _Note: Requires advanced knowledge on how WP Query and User Perms operate._ + + +### Design + +* **Layout and Style 99.9% Customizable** - There's nearly no limitations to the design, with some exceptions that may surface with (Child) Theme's CSS. This does require some knowledge in Web Design. *Note: This is NOT to be confused with Drag and Drop UI/UX.* +* **Internal Shortcodes** - Adds various data from Post object, and is one of the extensive features. Being able to extend to shortcodes with custom PHP functions make the possibilities practically limitless. [See full list & details][apl shortcodes]. +* **Encapsulated for Zero Conflicts** - With a large number of shortcodes on any given site. Isolating Internal Shortcodes to its own instance eliminates any plugin conflicts. +* **Custom Formats to Loop ( The Loop )** - Themes follow this concept, but APL turns that concept into a tool. The “List Content” loop, as well as the before & after, is where most of the work is done with preset HTML, CSS, JS, & PHP designs. It is also optional to set an Empty Message (No Posts Found) to display. + +### Placement + +* **Post List Shortcode** - User friendly method of adding Preset Post Lists to a section of a page. +* **Sidebar Widget** - Easier to use. However, adding post list shortcodes to the text sidebar also produces the same results. +* **PHP Hardcode** - For more extensive design work. There is a public function for displaying Preset Post Lists where WordPress support and functions for admins aren’t fully present. + +## Other Plugins Tested/Supported + +There's various plugins that offer a unique capability, and some of which APL can use as intended, but there are also some don't. Here is a list of popular plugins that have been tested and verified by Advanced Post List. + +* **Advanced Custom Fields** - Requires php_function shortcode. +* **WPML** - With WordPress Multilingual installed, additional Designs can be created for rendering a Post List in different languages. Posts/Pages are handled automatically and will display content in various languages. + +APL is open to development requests and welcomes those willing to report on any issues. + +## Help & Support + +Currently, information can be found in 2 different locations. This is due to recent changes, and is only temporary. + +* [Getting Started][apl getting started] +* [Documentation][apl docs] + * [Internal Shortcodes][apl shortcodes] +* [GitHub Wiki][github wiki] + +Questions/Bug Report submit thread / ticket at [WordPress][wp apl support] or [GitHub Issue / Tickets][github issues]. \ No newline at end of file diff --git a/admin/admin-dialog-internal-shortcodes.php b/admin/admin-dialog-internal-shortcodes.php index 88d3967..960068e 100644 --- a/admin/admin-dialog-internal-shortcodes.php +++ b/admin/admin-dialog-internal-shortcodes.php @@ -1,40 +1,58 @@ -

- __(Shortcodes:) __(Use these codes inside the list item content (will - throw errors if placed in before or after HTML fields).) -

- -

- * Time shortcodes have an optional format parameter. Format your - dates using these possible tokens: m=month, M=text month, F=full text - month, d=day, D=short text Day Y=4 digit year, y=2 digit year, H=hour, - i=minute, s=seconds. More tokens listed here: - http://php.net/manual/en/function.date.php. -

-

- Note: these shortcodes only work in the List item content box on this page. -

\ No newline at end of file + +
+
+

+ Shortcodes: Use these codes inside the list item content (will + throw errors if placed in before or after HTML fields). +

+ +

+ * Time shortcodes have an optional format parameter. Format your + dates using these possible tokens: m=month, M=text month, F=full text + month, d=day, D=short text Day Y=4 digit year, y=2 digit year, H=hour, + i=minute, s=seconds. More tokens listed here: + http://php.net/manual/en/function.date.php. +

+

+ Note: these shortcodes only work in the List item content box on this page. +

+
+
+ diff --git a/admin/admin-dialogs.php b/admin/admin-dialogs.php deleted file mode 100644 index 11a73ce..0000000 --- a/admin/admin-dialogs.php +++ /dev/null @@ -1,354 +0,0 @@ -
- -
-

- - Error: Display Message. -

-
- -
-

- This will overwrite the current preset. Are you sure? -

-
-
-

- Please type a name for your preset, or press 'load' on any of the - presets below to edit. -

-
-
-

- - Error: If you selected 'Require terms' you must select 'Include' - and/or select at least two terms. -

-
-
-

- - Error: If you selected 'Require Taxonomy' you must select 'Include' - and/or select at least two terms. If the current page does not have - any terms in this taxonomy. The post list may not display anything. -

-
-
-

- Error: No other taxonomies are being used within the post_type.

-
- -
-

- Cannot use (< > : \" / \\ | ? *).
Please rename your filename.

-
- -
-

- Post Types - Each (jQuiry UI) accordion contains a - separate individual post type. The default post types built into WordPress - are Post and Page. Any additional post types are dynamically added in - the manner WordPress does. Please Note: Each post/page can have only - one post type, which may explain why it has been divided by post types. -

-

- Post Parent – Each hierarchical post type has a Parent - selector for selecting which children pages to display. You can add - multiple Post Parents of dynamically add children pages according to - the Current Page. -

-

- Current Page – If selected, the post list will include - children pages from the current page being viewed. -

-

- Taxonomies – Each taxonomy is generally spit up in two - sections, and divided into separate tabs. Hierarchies (categories) are - located on the left, and non-hierarchies (tags) are located on the right. -

-

- Require Taxonomy - If more than one ‘Require Taxonomy’ - is checked and terms (or include) are selected, or 'any', then each - taxonomy must be required within the post type. -

-

- Require Terms - If selected, and more than one term - is checked, then each term must be required within the CPT/taxonomy - in order to be displayed in the post list. -

-

- Include Terms – If selected, the post list preset - will include any terms the current page/post has within the CTP/taxonomy. -

-

- Any - When checked, any terms will be included within - that CPT/taxonomy. -

-
- -
-

- Posts Status - Holds the settings to show which posts - to display based on the user visibility and/or the page states. To which - is only visible to the users with the necessary capabilities to view - them. -

- -

- List Amount - The numeric value of how many posts - you want the post list to display. Negative one (-1) will display - all the posts that are available after filtering. -

-

- Author Filter - Show or remove posts that were created - by a certain author, or authors. You can only choose between adding or - removing, not both. -

- -

- Order By - Choose which page properties to sort from. - All of which are built in params used in WP_Query. -

-

- Perm - Uses the user permission via. user - capabilities to determine what posts to display in the post list - to the visitor/user. -

-

- Ignore Sticky Posts - Meant for the built-in post type - (Posts) function. When checked, this will prevent sticky posts from - always displaying at the top of the post list. -

-

- Exclude Current Post - When checked, the current post - being viewed will be excluded from the post list. -

-

- Exclude Posts by ID - Add post/page IDs, seperated by - a comma (,), will prevent those posts from being added to the post list. -

-

- Exclude Duplicates from Current Post - In the 'order - that it is received', each preset post list being viewed will add - the post IDs to a global exclude list built into APL. When checked, - the preset post list will add the post IDs (listed at the time) to the - exclude filter settings in WP_Query. This will remove any posts that - have already been displayed to the user by the APL plugin. -

-
- -
-

- Empty Message - This container holds the HTML & CSS content - and if no posts are found to be listed in the preset. Then the preset post list will display - this message. If no Empty Message is found, then the post list will use - the Default Empty Message if enabled in the Plugin's Admin Settings. - Otherwise, the plugin will display nothing like it was originally set as. - Please Note: if you are using the Default Empty Message but you - don't want to display anything in a certain preset post list. Then simple - create an empty element to fall back on. For example, an empty 'span' HTML element. -

-

- Before List - Used to store any HTML & CSS code that - exists before the post/content listings. Useful for div, ul, ol, - tables, etc.. As well as storing CSS styling for IDs and Classes. -

-

- List Content - This where you design how your posts - are going to display in the post list. In here you can use HTML, CSS, - PHP (requires the PHP shortcode), and the plugin's internal - shortcodes. Info can be found at the bottom, or by clicking on the - shortcode info found below "List content". -

-

- After List - Used for ending any elements that are - still open, or to display a final message to the users/visitors. -

-
-
- -
- -

- Shortcodes: Use these codes inside the list item content (will - throw errors if placed in before or after HTML fields). -

- -

- * Time shortcodes have an optional format parameter. Format your - dates using these possible tokens: m=month, M=text month, F=full text - month, d=day, D=short text Day Y=4 digit year, y=2 digit year, H=hour, - i=minute, s=seconds. More tokens listed here: - http://php.net/manual/en/function.date.php. -

-

- Note: these shortcodes only work in the List item content box on this page. -

-
- */ - ?> - -
-

- Eventually this feature will be changed to provide a more accurate - preview of the post list and will be more balanced on the on the admin - page. Currently, the preview feature has difficulty displaying private - posts and displaying posts with a preset post list with dynamic features - (Current Page & Include Terms). The current query uses the current page - that you are viewing, and from the admin page, it provides limited results. -

-

- Later on, this feature will be changed to view the post list as if it - were on the selected page you want to preview from (only the post list - will display). As well as creating a dialog for it, which may or may not - have width & height params for the admin to utilize. -

-

- A more practical use to get an accurate preview just create a test - page/post to use to display the preset shortcode. Private posts will - show up in there, and dynamic features can be utilize. Of course, that - depends on how your test page/post is set up. -

-
- -
-

- General Plugin Settings - Controls the basic core/global - settings and actions of the plugin, and the admin section. -

-

- Delete Database Upon Deactivation - If 'No' is selected, - then the plugin's database data will not be removed when the plugin is - deactivated. When re-activated, the plugin data will restored as it - was left. Please Note: If the plugin is removed/uninstalled, - then the plugin's data will be removed regardless. -

-

- Admin jQuery UI Theme - Added as a simple extra to - change the appearance that the jQuery UI will display as. -

-

- Enable Default Empty Message - Used as a default option - to use if no posts are found and the Empty Message is empty within the - preset post list. - -

- -
- -
-

- Preset Database Tools - Tools for backing up, restoring, - or adding additional presets to the APL preset database. You can also - export/download individual presets simular to exporting the preset table. - If you'd like to share some of your own presets, then read these - Guidelines/Instructions for Submitting Presets - for more information. -

-

- Export Preset Table - Exports the whole APL preset - database/table. Illegal (< > : " / \ | , ? *) characters cannot be used - as the exported filename. -

-

- Import Preset(s) - Imports one or more presets, from - a 2 different sources, and is added to the database. Any older versions, - including Kalin's Post List (KPL), will automatically be upgraded, but - is limited to any versions higher than the current APL version being used. -

- -

- Restore Preset Defaults - Designed to restore only - the default preset table the plugin initially came with. -

-
- \ No newline at end of file diff --git a/admin/admin.php b/admin/admin.php deleted file mode 100644 index 08d092e..0000000 --- a/admin/admin.php +++ /dev/null @@ -1,704 +0,0 @@ -apl_options_load(); - -function APL_post_tax_content() -{ - $htmlContent = ''; - $post_type_names = get_post_types('', - 'names'); - - $skip_post_types = array('attachment', 'revision', 'nav_menu_item'); - foreach ($skip_post_types as $value) - { - unset($post_type_names[$value]); - } - - foreach ($post_type_names as $post_type_name) - { - $htmlContent .= APL_post_tax_get_accordion_content($post_type_name); - } - - echo $htmlContent; -} - -function APL_post_tax_get_accordion_content($post_type_name) -{ - $rtnString = ''; - - $post_type_object = get_post_type_object($post_type_name); - - $post_type_object->taxonomies = APL_get_taxonomy_object_names($post_type_name); - - $skip_taxonomies = array('post_format'); - foreach ($skip_taxonomies as $value) - { - unset($post_type_object->taxonomies[$value]); - } - - $rtnString .= '

' . $post_type_object->labels->singular_name . '

'; - $rtnString .= '
'; - //GET HEADER - $rtnString .= APL_post_tax_get_left_header($post_type_name); - $rtnString .= APL_post_tax_get_right_header(); - $rtnString .= '
'; - $rtnString .= APL_post_tax_get_taxonomy_section($post_type_name, - $post_type_object->taxonomies); - $rtnString .= '
'; - - $rtnString .= '
'; - return $rtnString; -} - -function APL_get_taxonomy_object_names($post_type_name) -{ - $rtnTaxonomyArray = array(); - - $taxonomy_names = get_taxonomies('', - 'names'); - foreach ($taxonomy_names as $taxonomy_name) - { - $taxonomy_object = get_taxonomy($taxonomy_name); - foreach ($taxonomy_object->object_type as $object_type_name) - { - if ($object_type_name === $post_type_name) - { - $rtnTaxonomyArray[$taxonomy_name] = $taxonomy_name; - } - } - } - - return $rtnTaxonomyArray; -} - -function APL_post_tax_get_left_header($post_type_name) -{ - $rtnString = ''; - - $rtnString .= '
'; - //$rtnString .= ''; - $rtnString .= '
'; - - return $rtnString; -} -function APL_post_tax_get_right_header() -{ - $rtnString = ''; - - $rtnString .= '
'; - $rtnString .= ''; - $rtnString .= '
'; - return $rtnString; - -} - - -function APL_post_tax_get_taxonomy_section($post_type_name, - $taxonomy_names) -{ - $rtnString = ''; - - $htmlCatTabs = ''; - $htmlCatTabsContent = ''; - $htmlTagTabs = ''; - $htmlTagTabsContent = ''; - - $htmlCatTabs .= '
'; - $htmlTagTabs .= '
'; - - $htmlCatTabs .= ''; - - $htmlCatTabsContent .= '
'; - $htmlTagTabsContent .= '
'; - - //Add Categories section - $rtnString .= $htmlCatTabs . $htmlCatTabsContent; - //Add Tags section - $rtnString .= $htmlTagTabs . $htmlTagTabsContent; - - return $rtnString; -} - -function APL_add_terms($post_type_name, - $taxonomy_name) -{ - $rtnString = ''; - $argTerms = array('hide_empty' => 0, 'taxonomy' => $taxonomy_name); - $terms = get_categories($argTerms); - - if (!empty($terms)) - { - $rtnString .= 'Any/All
'; - foreach ($terms as $value_tag) - { - $rtnString .= '' . $value_tag->name . '
'; - } - } - - - return $rtnString; -} - -function APL_get_page_selector_options($post_type_name = 'post') -{ - $rtnString = ''; - - $rtnString .= ''; - return $rtnString; - -} - -//TODO Change to use APLCore::apl_get_posts() instead of get_posts() -- May not -// be possible since the function inside the class is set to private. -//TODO Add parent (ID) variable to retrieve less data to cycle through. - -function APL_get_page_heirarchy($post_type_name = 'post', - $parent = 0, - $depth = -1) -{ - $rtnString = ''; - $dashes = ''; - - $depth++; - for ($i = 0; $i < $depth; $i++) - { - $dashes .= '-'; - } - - $argPages = array( - 'numberposts' => -1, - 'orderby' => 'title', - 'order' => 'ASC', - 'post_type' => $post_type_name, - 'post_parent' => $parent - ); - $pages = get_posts($argPages); - - foreach ($pages as $page) - { - if ($page->post_parent === $parent) - { - $id = $page->ID; - $rtnString .= ''; - $rtnString .= APL_get_page_heirarchy($post_type_name, - $id, - $depth); - } - } - - return $rtnString; -} - -function APL_get_cat_hierchy($post_tax_settings = array('post_type_name' => 'post', 'taxonomy_name' => 'category'), - $parent = 0, - $depth = -1) -{ - $argTerms = array('hide_empty' => 0, 'taxonomy' => $post_tax_settings['taxonomy_name']); - - $rtnString = ''; - $dashes = ''; - if ($depth == -1) - { - $rtnString .= 'Any/All
'; - } - $depth++; - for ($i = 0; $i < $depth; $i++) - { - $dashes .= '-'; - } - $terms = get_categories($argTerms); - - foreach ($terms as $term) - { - if ($term->parent == $parent) - { - $id = $term->term_id; - $rtnString .= '' . $dashes . $term->name . '
'; - - $rtnString .= APL_get_cat_hierchy($post_tax_settings, - $id, - $depth); - } - } - - return $rtnString; -} -//////////////////////////////////////////////////////////////////////////////// -//****************************************************************************// -//** END OF PHP **// -//****************************************************************************// -//////////////////////////////////////////////////////////////////////////////// -?> -
-
-

Advanced Post List - Settings

-
-
-

Plugin Page (WordPress / Wiki)

-
-
-
-
-
-
- -
-
-
-
- Filter Settings Info -
-
-
- - - -
-
- - -
-
-
-
- - - -
-
- - - -
-
-
-
- - -
-
- - - - -
-
-
-
- - -
-
- - -
-
-
-
-
-
- Style Content Info -
-
-
- - -
-
- - -
-
-
- - Shortcodes -
- -
-
- - -
-
-
- - - -   |   - -  (Results may vary Details) -
-
-
- Preview will appear here when saved -
-
-
- -
-
- PHP code - click load on any preset to generate PHP code for use in your theme -
-
-
-
-
-

General Options

-
-
-
-

Settings

-
-
- Settings Info -
-
- - -
-
- Delete database upon deactivation. -
-
- - /> - /> -
-
-
-
- Admin JQuery UI Theme -
-
- -
-
-
-
- Enable Default Empty Message: -
-
- - /> - /> -
-
-
- -
-
- -
-
-
-
-
-

Export Preset Table

-
-
- Export/Import Info -
-
-
-
- Filename: -
- -
-
-
-
-

Import Preset(s)

-
-
- -
-
-
-
- -
- -
- -
-
-
-
-

Restore Preset Defaults

-
-
-

Note: Restoring the plugin's default preset table will only overwrite/add the initial set of presets, and will not delete other presets of a different name. -

- -
-
-
-
- -
-
- -
-
- -
-
-
-
-
-
-

- Shortcodes: Use these codes inside the list item content (will throw errors if placed in before or after HTML fields)
-

- -

* Time shortcodes have an optional format parameter. Format your dates using these possible tokens: m=month, M=text month, F=full text month, d=day, D=short text Day Y=4 digit year, y=2 digit year, H=hour, i=minute, s=seconds. More tokens listed here: http://php.net/manual/en/function.date.php.

-

Note: these shortcodes only work in the List item content box on this page.

-
-
-
- - - diff --git a/admin/class-apl-admin.php b/admin/class-apl-admin.php new file mode 100644 index 0000000..6ebef49 --- /dev/null +++ b/admin/class-apl-admin.php @@ -0,0 +1,1879 @@ +_requires(); + + // Settings Data + add_action( 'admin_post_apl_save_general_settings', array( $this, 'save_general_settings' ) ); + // AJAX. + add_action( 'admin_init', array( $this, 'add_settings_ajax_hooks' ) ); + + // Check if wp-admin.php is loaded, and WP_Screen is defined. + if ( defined( 'WP_ADMIN' ) && WP_ADMIN && is_blog_admin() ) { + // Menu & Scripts. + add_action( 'admin_menu', array( $this, 'admin_menu' ) ); + add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue' ) ); + + // Admin Screens for Modular Screen Execution. + // NOTE: Settings Page needs to hook sooner (in constructor/here). + add_action( 'current_screen', array( $this, 'current_screen_hooks' ) ); + + // Hook into WP to customize Screens. + add_action( 'admin_head', array( $this, 'disable_screen_boxes' ) ); + add_action( 'load-edit.php', array( $this, 'post_list_screen_options_all' ) ); + add_action( 'load-post-new.php', array( $this, 'post_list_screen_options_add_new' ) ); + + add_action( 'manage_apl_post_list_posts_columns', array( $this, 'post_list_posts_columns' ) ); + add_action( 'manage_apl_post_list_posts_custom_column', array( $this, 'post_list_posts_custom_column' ), 10, 2 ); + add_action( 'manage_edit-apl_post_list_sortable_columns', array( $this, 'post_list_sortable_columns' ) ); + + // Editor Meta Boxes. + add_action( 'add_meta_boxes', array( $this, 'post_list_meta_boxes' ) ); + add_action( 'add_meta_boxes', array( $this, 'settings_meta_boxes' ) ); + if ( defined( 'ICL_SITEPRESS_VERSION' ) ) { + add_action( 'add_meta_boxes', array( $this, 'design_meta_boxes' ) ); + } + } + } + + /** + * Current Admin Screen Hooks + * + * Adds hooks according to the admin screen in use. + * + * @since 0.4.0 + * + * @param WP_Screen $current_screen Current WP_Screen object. + */ + public function current_screen_hooks( $current_screen ) { + if ( 'apl_post_list' === $current_screen->id || 'edit-apl_post_list' === $current_screen->id ) { + /* ALL POST LISTS */ + // Post Data + add_action( 'draft_apl_post_list', array( $this, 'draft_post_list' ), 10, 2 ); + + add_action( 'private_apl_post_list', array( $this, 'save_post_list' ), 10, 2 ); + add_action( 'publish_apl_post_list', array( $this, 'save_post_list' ), 10, 2 ); + add_action( 'pending_apl_post_list', array( $this, 'save_post_list' ), 10, 2 ); + add_action( 'future_apl_post_list', array( $this, 'save_post_list' ), 10, 2 ); + + //add_action( 'trash_apl_post_list', array( $this, 'trash_post_list' ), 10, 3 ); + add_action( 'wp_trash_post', array( $this, 'action_wp_trash_post_apl_post_list' ) ); + add_action( 'untrash_post', array( $this, 'action_untrash_post_apl_post_list' ) ); + add_action( 'before_delete_post', array( $this, 'action_before_delete_post_apl_post_list' ) ); + + if ( 'apl_post_list' === $current_screen->id ) { + $current_screen->add_help_tab( array( + 'id' => 'apl_post_list_help', //unique id for the tab. + 'title' => 'Testing Help Tab', //unique visible title for the tab. + 'content' => 'Hello World', //actual help text. + //'callback' => $callback //optional function to callback. + ) ); + } + } elseif ( 'apl_design' === $current_screen->id || 'edit-apl_design' === $current_screen->id ) { + // Post Data + add_action( 'draft_apl_design', array( $this, 'draft_design' ), 10, 2 ); + + add_action( 'private_apl_design', array( $this, 'save_design' ), 10, 2 ); + add_action( 'publish_apl_design', array( $this, 'save_design' ), 10, 2 ); + add_action( 'pending_apl_design', array( $this, 'save_design' ), 10, 2 ); + add_action( 'future_apl_design', array( $this, 'save_design' ), 10, 2 ); + + ////add_action( 'trash_apl_post_list', array( $this, 'trash_design' ), 10, 3 ); + //add_action( 'wp_trash_post', array( $this, 'action_wp_trash_post_apl_design' ) ); + //add_action( 'untrash_post', array( $this, 'action_untrash_post_apl_design' ) ); + //add_action( 'before_delete_post', array( $this, 'action_before_delete_post_apl_design' ) ); + } elseif ( 'adv-post-list_page_apl_settings' === $current_screen->id ) { + /* SETTINGS (Page) */ + // DOES NOT always work as intended. Use self::_constructor(). + }// End if(). + + } + + /** + * Requires Files + * + * Files that this class object needs to load. + * + * @ignore + * @since 0.4.0 + * @access private + */ + private function _requires() { + // Example. + // 'require_once( APL_DIR . 'includes/example.php' )'. + require_once( APL_DIR . 'admin/export.php' ); + require_once( APL_DIR . 'admin/import.php' ); + } + + /** + * APL Admin Menu + * + * Adds the Admin Menu and Scripts for APL. + * + * @since 0.4.0 + * + * @see 'admin_menu' hook + * @see wp-admin/admin-header.php + * @link https://developer.wordpress.org/reference/functions/add_menu_page/ + * @link https://developer.wordpress.org/reference/functions/add_submenu_page/ + */ + public function admin_menu() { + add_menu_page( + __( 'Advanced Post List', 'advanced-post-list' ), + __( 'Adv. Post List', 'advanced-post-list' ), + 'administrator', + 'advanced_post_list', + 'edit.php?post_type=apl_post_list', // Callback function if dashboard is added. + 'dashicons-welcome-widgets-menus', + 58 + ); + + // TODO Add APL Dashboard. + + // All Post Lists (Submenu) - Submenu setting is added during CPT registration. + // Add New (Submenu). + add_submenu_page( + 'advanced_post_list', + __( 'Add New Post List', 'advanced-post-list' ), + __( 'Add New', 'advanced-post-list' ), + 'administrator', + 'post-new.php?post_type=apl_post_list' + ); + + // Settings (Submenu). + add_submenu_page( + 'advanced_post_list',// edit.php?post_type=apl_post_list', + __( 'APL Settings', 'advanced-post-list' ), + __( 'Settings', 'advanced-post-list' ), + 'administrator', + 'apl_settings', + array( $this, 'submenu_settings_page' ) + ); + add_action( 'admin_init', array( $this, 'settings_register_settings' ) ); + + // TODO - Add Help API. + + // EXTENSIONS + do_action( 'apl_admin_menu_ext' ); + + } + + /** + * Submenu Callback for Settings Page + * + * @since 0.4.0 + */ + public function submenu_settings_page() { + include( APL_DIR . 'admin/settings-page.php' ); + } + + /** + * Registers Input Settings for Settings Page + * + * @since 0.4.0 + */ + public function settings_register_settings() { + register_setting( 'apl_settings_general', 'apl_delete_on_deactivation', 'strval' ); + register_setting( 'apl_settings_general', 'apl_default_empty_enable', 'strval' ); + register_setting( 'apl_settings_general', 'apl_default_empty_message', 'strval' ); + + //register_setting( 'apl_settings_import_export', 'apl_export_file_name', 'strval' ); + //register_setting( 'apl_settings_import_export', 'apl_import_opt', 'strval' ); + //register_setting( 'apl_settings_import_export', 'apl_import_file', 'strval' ); + //register_setting( 'apl_settings_import_export', 'apl_restore_database', 'strval' ); + } + + /** + * APL Admin Enqueue Scripts & Styles + * + * Loads APL scripts and styles. If not in APL Admin Pages, then remove. + * + * @since 0.4.0 + * + * @see wp-admin/admin-header.php + * @link https://developer.wordpress.org/reference/hooks/admin_enqueue_scripts/ + * + * @param string $hook_suffix The suffix for the current Admin page. + */ + public function admin_enqueue( $hook_suffix ) { + $screen = get_current_screen(); + + /* + * ************** REMOVE SCRIPTS & STYLES ********************* + */ + + // STEP 1 - By default, remove any scripts & styles. + wp_deregister_script( 'apl-admin-js' ); + wp_deregister_script( 'apl-admin-ui-js' ); + wp_deregister_script( 'apl-admin-ui-multiselect-js' ); + wp_deregister_script( 'apl-admin-ui-multiselect-filter-js' ); + + wp_deregister_style( 'apl-admin-css' ); + wp_deregister_style( 'apl-admin-ui-multiselect-css' ); + wp_deregister_style( 'apl-admin-ui-multiselect-filter-css' ); + wp_deregister_style( 'apl-admin-settings-css' ); + + if ( 'apl_post_list' === $screen->id || 'edit-apl_post_list' === $screen->id || 'apl_design' === $screen->id || 'edit-apl_design' === $screen->id ) { + + /* + * ************** AJAX ACTION HOOKS *************************** + */ + + // TODO - Add meta box to side to load different presets from 'edit.php'. + //add_action( 'wp_ajax_apl_load_preset', array( $this, 'hook_ajax_load_preset' ) ); + + /* + * ************** REGISTER SCRIPTS **************************** + */ + + // Step 2 - Register scripts to be enqueued. + wp_register_script( + 'apl-admin-js', + APL_URL . 'admin/js/admin.js', + array( + 'jquery', + ), + APL_VERSION, + false + ); + + wp_register_script( + 'apl-admin-ui-js', + APL_URL . 'admin/js/admin-ui.js', + array( + 'jquery', + 'jquery-ui-core', + 'jquery-ui-widget', + 'jquery-ui-tabs', + 'jquery-ui-spinner', + 'jquery-ui-slider', + 'jquery-ui-button', + 'jquery-ui-dialog', + 'jquery-ui-selectmenu', + 'jquery-ui-position', + 'jquery-ui-tooltip', + + ), + APL_VERSION, + true + ); + + wp_register_script( + 'apl-admin-ui-multiselect-js', + APL_URL . 'admin/js/jquery.multiselect.min.js', + array( + 'jquery', + 'jquery-ui-core', + 'jquery-ui-widget', + 'jquery-ui-selectmenu', + ), + APL_VERSION, + false + ); + + wp_register_script( + 'apl-admin-ui-multiselect-filter-js', + APL_URL . 'admin/js/jquery.multiselect.filter.min.js', + array( + 'jquery', + 'jquery-ui-core', + 'jquery-ui-widget', + ), + APL_VERSION, + false + ); + + // STEP 3 - Enqueue scripts. + wp_enqueue_script( 'apl-admin-js' ); + wp_enqueue_script( 'apl-admin-ui-js' ); + wp_enqueue_script( 'apl-admin-ui-multiselect-js' ); + wp_enqueue_script( 'apl-admin-ui-multiselect-filter-js' ); + + /* + * ************** REGISTER STYLES ***************************** + */ + + // Step 4 - (Register) Enqueue styles. + wp_enqueue_style( + 'apl-admin-css', + APL_URL . 'admin/css/admin.css', + false, + APL_VERSION, + false + ); + + $wp_scripts = wp_scripts(); + wp_enqueue_style( + 'apl-admin-ui-css', + 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $wp_scripts->registered['jquery-ui-core']->ver . '/themes/smoothness/jquery-ui.css', + false, + APL_VERSION, + false + ); + + wp_enqueue_style( + 'apl-admin-ui-multiselect-css', + APL_URL . 'admin/css/jquery.multiselect.css', + false, + APL_VERSION, + false + ); + + wp_enqueue_style( + 'apl-admin-ui-multiselect-filter-css', + APL_URL . 'admin/css/jquery.multiselect.filter.css', + false, + APL_VERSION, + false + ); + + // Get values for variables to localize into JS files. + // POST => TAXONOMIES. + $data_post_tax = $this->get_post_tax(); + + // TAXONOMIES => TERMS. + $data_tax_terms = $this->get_tax_terms(); + + $data_ui_trans = array( + 'tax_noneSelectedText' => esc_html__( 'Select Taxonomy', 'advanced-post-list' ), + 'tax_selectedText' => esc_html__( '# of # taxonomies selected', 'advanced-post-list' ), + 'author_ids_noneSelectedText' => esc_html__( '- None -', 'advanced-post-list' ), + 'author_ids_selectedText' => esc_html__( '# Selected', 'advanced-post-list' ), + 'post_status_1_noneSelectedText' => esc_html__( 'Select Status', 'advanced-post-list' ), + 'post_status_1_selectedText' => esc_html__( 'Both', 'advanced-post-list' ), + 'post_status_2_noneSelectedText' => esc_html__( 'Published', 'advanced-post-list' ), + 'post_status_2_selectedText' => esc_html__( '# Selected', 'advanced-post-list' ), + ); + + $admin_localize = array(); + $admin_ui_localize = array( + 'post_tax' => $data_post_tax, + 'tax_terms' => $data_tax_terms, + 'trans' => $data_ui_trans, + ); + + // Add variables to JS files. + // '../admin/js/admin.js'. + // '../admin/js/admin-ui.js'. + wp_localize_script( 'apl-admin-js', 'apl_admin_local', $admin_localize ); + wp_localize_script( 'apl-admin-ui-js', 'apl_admin_ui_local', $admin_ui_localize ); + //} elseif ( 'apl_design' === $screen->id || 'edit-apl_design' === $screen->id ) { + // TODO Add handling APL Designs without extra code from APL_Post_Lists.. + } elseif ( 'adv-post-list_page_apl_settings' === $screen->id ) { + // If we are not viewing APL Post List area, then return. + // SETTINGS PAGE + + // SCRIPTS. + wp_register_script( + 'apl-settings-js', + APL_URL . 'admin/js/settings.js', + array( + 'jquery', + 'jquery-ui-core', + 'jquery-ui-widget', + //'jquery-ui-position', + 'jquery-ui-button', + //'jquery-ui-draggable', + //'jquery-ui-resizable', + //'jquery-ui-effect', + 'jquery-ui-dialog', + //'jquery-ui-progressbar', + ), + APL_VERSION, + true + ); + wp_register_script( + 'apl-settings-ui-js', + APL_URL . 'admin/js/settings-ui.js', + array( + 'jquery', + 'jquery-ui-core', + 'jquery-ui-widget', + 'jquery-ui-dialog', + 'jquery-ui-position', + 'jquery-ui-tooltip', + ), + APL_VERSION, + true + ); + + //wp_enqueue_script( 'common' ); + //wp_enqueue_script( 'wp-lists' ); + wp_enqueue_script( 'postbox' ); + wp_enqueue_script( 'apl-settings-js' ); + wp_enqueue_script( 'apl-settings-ui-js' ); + + // STYLES. + wp_enqueue_style( + 'apl-admin-settings-css', + APL_URL . 'admin/css/settings.css', + false, + APL_VERSION, + false + ); + + $wp_scripts = wp_scripts(); + wp_enqueue_style( + 'apl-admin-ui-css', + 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $wp_scripts->registered['jquery-ui-core']->ver . '/themes/smoothness/jquery-ui.css', + false, + APL_VERSION, + false + ); + + $trans_arr = array( + 'default_alert_title' => __( 'Alert', 'advanced-post-list' ), + 'default_alert_message' => __( 'No Message to Display.', 'advanced-post-list' ), + 'fileName_empty_alert_title' => __( 'Filename Required', 'advanced-post-list' ), + 'fileName_empty_alert_message' => __( 'A filename doesn\'t exist. \n Please enter a filename before exporting.', 'advanced-post-list' ), + 'import_no_file_message' => __( 'No file(s) selected. Please choose a JSON file to upload.', 'advanced-post-list' ), + 'import_no_file_title' => __( 'No File', 'advanced-post-list' ), + 'import_invalid_file_message' => __( 'Invalid file type. Please choose a JSON file to upload.', 'advanced-post-list' ), + 'import_invalid_file_title' => __( 'Invalid File', 'advanced-post-list' ), + 'import_success_message' => __( 'Data successfully imported.', 'advanced-post-list' ), + 'import_success_title' => __( 'Complete', 'advanced-post-list' ), + 'import_overwrite_dialog_title' => __( 'Overwrite Presets', 'advanced-post-list' ), + 'fileName_char_alert_title' => __( 'Illegal Characters', 'advanced-post-list' ), + 'fileName_char_alert_message1' => __( 'Cannot use (< > : " / \\ | , ? *).', 'advanced-post-list' ), + 'fileName_char_alert_message2' => __( 'Please rename your filename.', 'advanced-post-list' ), + + ); + $trans_ui_arr = array( + 'fileName_char_alert_title' => __( 'Illegal Characters', 'advanced-post-list' ), + 'fileName_char_alert_message1' => __( 'Cannot use (< > : " / \\ | , ? *).', 'advanced-post-list' ), + 'fileName_char_alert_message2' => __( 'Please rename your filename.', 'advanced-post-list' ), + ); + + $settings_localize = array( + 'export_nonce' => wp_create_nonce( 'apl_settings_export' ), + 'import_nonce' => wp_create_nonce( 'apl_settings_import' ), + 'restore_nonce' => wp_create_nonce( 'apl_settings_restore' ), + 'trans' => $trans_arr, + ); + $settings_ui_localize = array( + 'trans' => $trans_ui_arr, + ); + + wp_localize_script( 'apl-settings-js', 'apl_settings_local', $settings_localize ); + wp_localize_script( 'apl-settings-ui-js', 'apl_settings_ui_local', $settings_ui_localize ); + + do_action( 'add_meta_boxes', $hook_suffix ); + add_screen_option( 'layout_columns', array( 'max' => 2, 'default' => 2 ) ); + + }// End if(). + } + + /** + * Disables/Hides Screen Option Settings + * + * Disables / Hides the Screen Option's display Meta Boxes Settings. Basically + * prevents certain Meta Boxes from being hidden, and forces the box to display. + * + * @since 0.4.0 + * + * @see 'admin_head' hook. + * @link https://wordpress.stackexchange.com/questions/149602/hiding-metabox-from-screen-options-pull-down + */ + public function disable_screen_boxes() { + echo ''; + echo ''; + } + + /** + * Screen Options for 'All Post List' page + * + * Hook 'load-edit.php', sets additional Screen Options. + * + * @see 'load-edit.php' hook. + * @since 0.4.0 + */ + public function post_list_screen_options_all() { + $screen = get_current_screen(); + // Get out of here if we are not on our settings page. + if ( ! is_object( $screen ) || 'edit-apl_post_list' !== $screen->id ) { + return; + } + + $options = $screen->get_options(); + } + + /** + * Screen Options for 'Add New' page + * + * Hook 'load-post-new.php', sets additional Screen Options. + * + * @see 'load-post-new.php' hook. + * @since 0.4.0 + */ + public function post_list_screen_options_add_new() { + $screen = get_current_screen(); + // Get out of here if we are not on our settings page. + if ( ! is_object( $screen ) || 'apl_post_list' !== $screen->id ) { + return; + } + $options = $screen->get_options(); + } + + /** + * Post List All Posts Columns + * + * Adds additional columns to All Post Lists page. + * + * @since 0.4.0 + * + * @see 'manage_apl_post_list_posts_columns' + * @uses manage_${post_type}_posts_columns + * @link https://codex.wordpress.org/Plugin_API/Filter_Reference/manage_$post_type_posts_columns + * + * @param type $columns Columns use in the 'All Post Lists' page. + * @return array + */ + public function post_list_posts_columns( $columns ) { + $tmp_date = $columns['date']; + unset( $columns['date'] ); + + $columns['post_name'] = __( 'Slug', 'advanced-post-list' ); + $columns['apl_shortcode'] = __( 'Shortcode', 'advanced-post-list' ); + + $columns['date'] = $tmp_date; + + return $columns; + } + + /** + * Post List Custom Column + * + * Adds content to custom column. + * + * @since 0.4.0 + * + * @uses manage_${post_type}_posts_columns hook. + * @link https://codex.wordpress.org/Plugin_API/Action_Reference/manage_$post_type_posts_custom_column + * + * @param type $column + * @param type $post_id + */ + public function post_list_posts_custom_column( $column, $post_id ) { + $args = array( + 'post__in' => array( $post_id ), + 'post_type' => 'apl_post_list', + 'post_status' => array( + 'draft', + 'pending', + 'publish', + 'future', + 'private', + 'trash', + ), + ); + $post_lists = new WP_Query( $args ); + $post_list = $post_lists->post; + + switch ( $column ) { + case 'post_name' : + echo $post_list->post_name; + break; + case 'apl_shortcode' : + echo ''; + break; + } + } + + /** + * Post List Sortable Columns + * + * Sets Custom Columns to be sortable. + * + * @param array $columns + * @return string + */ + public function post_list_sortable_columns( $columns ) { + $columns['post_name'] = 'post_name'; + + return $columns; + } + + /** + * Post List Meta Boxes + * + * Hook 'add_meta_boxes', adds meta boxes used in post lists. + * + * @since 0.4.0 + * + * @see $this->_construct Used by. + * @see 'add_meta_boxes' hook. + * @see wp-admin/includes/template.php + * @link https://codex.wordpress.org/Plugin_API/Action_Reference/add_meta_boxes + * @link https://developer.wordpress.org/reference/functions/add_meta_box/ + */ + public function post_list_meta_boxes() { + add_meta_box( + 'apl-post-list-filter', + __( 'Filter Settings', 'advanced-post-list' ), + array( $this, 'post_list_meta_box_filter' ), + 'apl_post_list', + 'normal', // 'normal', 'advanced', 'side'. + 'high' // 'high', 'sorted', 'core', 'default', 'low'. + ); + add_meta_box( + 'apl-post-list-display', + __( 'Display Settings', 'advanced-post-list' ), + array( $this, 'post_list_meta_box_design' ), + 'apl_post_list', + 'normal', + 'core' + ); + } + + /** + * Design Meta Boxes + * + * Hook 'add_meta_boxes', adds meta boxes used in designs. + * + * @since 0.4.0 + * + * @see $this->_construct Used by. + * @see 'add_meta_boxes' hook. + * @see wp-admin/includes/template.php + * @link https://codex.wordpress.org/Plugin_API/Action_Reference/add_meta_boxes + * @link https://developer.wordpress.org/reference/functions/add_meta_box/ + */ + public function design_meta_boxes() { + add_meta_box( + 'apl-post-list-display', + __( 'Display Settings', 'advanced-post-list' ), + array( $this, 'design_meta_box_design' ), + 'apl_design', + 'normal', + 'core' + ); + } + + /** + * Add Settings Page Meta Boxes + * + * @see $this->_construct Used by. + * @see 'add_meta_boxes' hook. + * @see add_meta_box(); + * @link https://codex.wordpress.org/Plugin_API/Action_Reference/add_meta_boxes + * @link https://developer.wordpress.org/reference/functions/add_meta_box/ + */ + public function settings_meta_boxes() { + add_meta_box( + 'apl-info', + __( 'About', 'advanced-post-list' ), + array( $this, 'settings_meta_box_info' ), + 'adv-post-list_page_apl_settings', + 'side', // 'normal', 'advanced', 'side'. + 'core' // 'high', 'sorted', 'core', 'default', 'low'. + ); + // TODO - Add Documentation Link to Admin Page/Metabox documentation. + //$title = 'Export/Import Info'; + add_meta_box( + 'apl-general', + //$title . __( 'General Settings', 'advanced-post-list' ), + __( 'General Settings', 'advanced-post-list' ), + array( $this, 'settings_meta_box_general' ), + 'adv-post-list_page_apl_settings', + 'normal', // 'normal', 'advanced', 'side'. + 'high' // 'high', 'sorted', 'core', 'default', 'low'. + ); + add_meta_box( + 'apl-import-export', + __( 'Import / Export', 'advanced-post-list' ), + array( $this, 'settings_meta_box_import_export' ), + 'adv-post-list_page_apl_settings', + 'advanced', + 'core' + ); + } + + /** + * Settings Info Meta Box + * + * @since 0.4.0 + * + * @param WP_Post $post Current WP_Post object. + * @param array $metabox With Meta Box id, title, callback, and args elements. + */ + public function settings_meta_box_info( $post, $metabox ) { + include( APL_DIR . 'admin/settings-meta-box-info.php' ); + } + + /** + * Settings General Settings Meta Box + * + * @since 0.4.0 + * + * @param WP_Post $post Current WP_Post object. + * @param array $metabox With Meta Box id, title, callback, and args elements. + */ + public function settings_meta_box_general( $post, $metabox ) { + include( APL_DIR . 'admin/settings-meta-box-general.php' ); + } + + /** + * Settings Import/Export Meta Box + * + * @since 0.4.0 + * + * @param WP_Post $post Current WP_Post object. + * @param array $metabox With Meta Box id, title, callback, and args elements. + */ + public function settings_meta_box_import_export( $post, $metabox ) { + include( APL_DIR . 'admin/settings-meta-box-import-export.php' ); + } + + /** + * Post List Filter Meta box Template + * + * @since 0.4.0 + * + * @param WP_Post $post Current WP_Post object. + * @param array $metabox With Meta Box id, title, callback, and args elements. + */ + public function post_list_meta_box_filter( $post, $metabox ) { + $apl_post_tax = $this->get_post_tax(); + $apl_tax_terms = $this->get_tax_terms(); + $apl_display_post_types = apl_get_display_post_types(); + + include( APL_DIR . 'admin/post-list-meta-box-filter.php' ); + } + + /** + * Post List Design Meta box Template + * + * Hook '$this->post_list_meta_boxes()', renders the Design Meta Box Template. + * + * @since 0.4.0 + * + * @param WP_Post $post Current WP_Post object. + * @param array $metabox With Meta Box id, title, callback, and args elements. + */ + public function post_list_meta_box_design( $post, $metabox ) { + include( APL_DIR . 'admin/post-list-meta-box-design.php' ); + } + + /** + * Post List Design Meta box Template + * + * Renders the Design Meta Box Template. + * + * @see self::design_meta_boxes() + * @since 0.4.0 + * + * @param WP_Post $post Current WP_Post object. + * @param array $metabox With Meta Box id, title, callback, and args elements. + */ + public function design_meta_box_design( $post, $metabox ) { + include( APL_DIR . 'admin/post-list-meta-box-design.php' ); + } + + /** + * Draft Post List + * + * Hook for draft Post Transitions with Post Lists. + * + * @since 0.4.0 + * + * @param int $post_id + * @param WP_Post $post + */ + public function draft_post_list( $post_id, $post ) { + if ( isset( $_REQUEST['action'] ) ) { + if ( 'untrash' === $_REQUEST['action'] ) { + return; + } + } + if ( empty( $post->post_name ) ) { + if ( empty( $post->post_title ) ) { + $post->post_title = 'APL-' . $post->ID; + } + + remove_action( 'draft_apl_post_list', array( $this, 'draft_post_list' ) ); + $post->post_name = sanitize_title_with_dashes( $post->post_title ); + + $postarr = array( + 'ID' => $post->ID, + 'post_title' => $post->post_title, + 'post_name' => $post->post_name, + //'post_status' => $post->post_status, + ); + wp_update_post( $postarr ); + + add_action( 'draft_apl_post_list', array( $this, 'draft_post_list' ), 10, 2 ); + } + + $this->post_list_process( $post_id, $post ); + } + + /** + * Save Post List + * + * Hook for saving object during post transitions. + * + * @since 0.4.0 + * + * @see self::current_screen_hooks() Used by. + * @see private_apl_post_list hook. + * @see publish_apl_post_list hook. + * @see pending_apl_post_list hook. + * @see future_apl_post_list hook. + * @see {status}_{post_type} Hook Transitions. + * @link https://codex.wordpress.org/Post_Status_Transitions + * + * @param int $post_id Old post ID. + * @param WP_Post $post Current Post object. + */ + public function save_post_list( $post_id, $post ) { + // CHECK AJAX REFERENCE. + + // ACTION = editpost + // Doesn't work if there is no action ( Add New ) + //check_admin_referer( 'update-post_' . $post_id ); + + //add_action( 'private_apl_post_list', array( $this, 'save_post_list' ), 10, 2 ); + //add_action( 'publish_apl_post_list', array( $this, 'save_post_list' ), 10, 2 ); + //add_action( 'pending_apl_post_list', array( $this, 'save_post_list' ), 10, 2 ); + //add_action( 'future_apl_post_list', array( $this, 'save_post_list' ), 10, 2 ); + + $this->post_list_process( $post_id, $post ); + + } + + /** + * Draft Design + * + * Hook for draft Post Transitions with Designs. + * + * @since 0.4.0 + * + * @param int $post_id Post ID. + * @param WP_Post $post (New) Post Data content. + */ + public function draft_design( $post_id, $post ) { + if ( isset( $_REQUEST['action'] ) ) { + if ( 'untrash' === $_REQUEST['action'] ) { + return; + } + } + + if ( empty( $post->post_name ) ) { + if ( empty( $post->post_title ) ) { + $post->post_title = 'APL-' . $post->ID; + } + + remove_action( 'draft_apl_design', array( $this, 'draft_design' ) ); + $post->post_name = sanitize_title_with_dashes( $post->post_title ); + + $postarr = array( + 'ID' => $post->ID, + 'post_title' => $post->post_title, + 'post_name' => $post->post_name, + ); + wp_update_post( $postarr ); + + add_action( 'draft_apl_design', array( $this, 'draft_design' ), 10, 2 ); + } + + $this->design_process( $post_id, $post ); + } + + /** + * Save Design + * + * Hook for saving object during post transitions. + * + * @since 0.4.0 + * + * @see self::current_screen_hooks() Used by. + * @see private_apl_design hook. + * @see publish_apl_design hook. + * @see pending_apl_design hook. + * @see future_apl_design hook. + * @see {status}_{post_type} Hook Transitions. + * @link https://codex.wordpress.org/Post_Status_Transitions + * + * @param int $post_id Old post ID. + * @param WP_Post $post Current Post object. + */ + public function save_design( $post_id, $post ) { + $this->design_process( $post_id, $post ); + } + + /** + * WP_Trash_Post APL Post List + * + * Host for trash post transitions with Post Lists. + * + * @since 0.4.0 + * + * @param type $post_id + * @return boolean + */ + public function action_wp_trash_post_apl_post_list( $post_id ) { + $args = array( + 'post__in' => array( $post_id ), + 'post_type' => 'apl_post_list', + //'post_status' => 'trash', + ); + $post_lists = new WP_Query( $args ); + if ( 1 > $post_lists->post_count ) { + return false; + } + $post_list = $post_lists->post; + + if ( 'apl_post_list' !== $post_list->post_type ) { + return; + } + + $apl_post_list = new APL_Post_List( $post_list->post_name ); + + $apl_design = new APL_Design( $apl_post_list->pl_apl_design ); + + $new_post_list_slug = $post_list->post_name . '__trashed'; + $new_design_slug = ''; + if ( ! empty( $post_list->post_name ) ) { + //$slug_suffix = apply_filters( 'apl_design_slug_suffix', '-design' ); + $design_slug = apply_filters( 'apl_design_trash_slug', $new_post_list_slug ); + //$new_design_slug = $design_slug . $slug_suffix; + $new_design_slug = $design_slug; + } + $apl_post_list->pl_apl_design = $new_design_slug; + $apl_design->slug = $new_design_slug; + + $apl_design->save_design(); + } + + /** + * Un-Trash for Post List + * + * Hook for untrash Post Transition with Post Lists. + * + * @since 0.4.0 + * + * @param int $post_id + * @return boolean + */ + public function action_untrash_post_apl_post_list( $post_id ) { + $args = array( + 'post__in' => array( $post_id ), + 'post_type' => 'apl_post_list', + 'post_status' => 'trash', + ); + $post_lists = new WP_Query( $args ); + if ( 1 > $post_lists->post_count ) { + return false; + } + $post_list = $post_lists->post; + + if ( 'apl_post_list' !== $post_list->post_type ) { + return; + } + + $apl_post_list = new APL_Post_List( $post_list->post_name ); + + $apl_design = new APL_Design( $apl_post_list->pl_apl_design ); + + $new_post_list_slug = str_replace( '__trashed', '', $post_list->post_name ); + $new_design_slug = ''; + if ( ! empty( $post_list->post_name ) ) { + //$slug_suffix = apply_filters( 'apl_design_slug_suffix', '-design' ); + $design_slug = apply_filters( 'apl_design_trash_slug', $new_post_list_slug ); + //$new_design_slug = $design_slug . $slug_suffix; + $new_design_slug = $design_slug; + } + $apl_post_list->pl_apl_design = $new_design_slug; + $apl_design->slug = $new_design_slug; + + $apl_design->save_design(); + } + + /** + * WP_Delete_Post APL Post List + * + * Host for delete post transitions with Post Lists. + * + * @since 0.4.0 + * @see https://codex.wordpress.org/Plugin_API/Action_Reference/before_delete_post + * + * @param int $post_id + * @return boolean + */ + public function action_before_delete_post_apl_post_list( $post_id ) { + $args = array( + 'post__in' => array( $post_id ), + 'post_type' => 'apl_post_list', + 'post_status' => 'trash', + ); + $post_lists = new WP_Query( $args ); + if ( 1 > $post_lists->post_count ) { + return false; + } + $post_list = $post_lists->post; + + if ( 'apl_post_list' !== $post_list->post_type ) { + return; + } + + $apl_post_list = new APL_Post_List( $post_list->post_name ); + $apl_design = new APL_Design( $apl_post_list->pl_apl_design ); + + $apl_design->delete_design(); + } + + /** + * Save General Settings + * + * Uses a lazy REST API built into WP. + * + * @uses Hook 'admin_post_{SCREEN ID}' ex. 'admin_post_apl_save_general_settings'. + * @link https://developer.wordpress.org/reference/hooks/admin_post_action/ + */ + public function save_general_settings() { + if ( ! is_admin() ) { + wp_die(); + } + $options = apl_options_load(); + + $tmp_ignore_pt = array(); + $post_types = get_post_types( '', 'names' ); + foreach ( $post_types as $post_type ) { + if ( isset( $_POST[ 'apl_ignore_pt_' . $post_type ] ) ) { + $input = filter_input( INPUT_POST, 'apl_ignore_pt_' . $post_type, FILTER_SANITIZE_STRING ); + $tmp_ignore_pt[ $post_type ] = sanitize_key( $input ); + } + } + $options['ignore_post_types'] = $tmp_ignore_pt; + + if ( isset( $_POST['apl_delete_on_deactivate'] ) ) { + $input = filter_input( INPUT_POST, 'apl_delete_on_deactivate', FILTER_SANITIZE_STRING ); + if ( 'yes' === $input ) { + $options['delete_core_db'] = true; + } elseif ( 'no' === $input ) { + $options['delete_core_db'] = false; + } else { + $options['delete_core_db'] = false; + } + } + + if ( isset( $_POST['apl_default_empty_enable'] ) ) { + $input = filter_input( INPUT_POST, 'apl_delete_on_deactivate', FILTER_SANITIZE_STRING ); + if ( 'yes' === $input ) { + $options['default_empty_enable'] = true; + } elseif ( 'no' === $input ) { + $options['default_empty_enable'] = false; + } else { + $options['default_empty_enable'] = true; + } + } + + $options['default_empty_output'] = ''; + if ( isset( $_POST['apl_default_empty_message'] ) ) { + // Sanatize with admins? + $tmp_empty_messaage = filter_input( INPUT_POST, 'apl_default_empty_message', FILTER_UNSAFE_RAW ); + $options['default_empty_output'] = $tmp_empty_messaage; + } + + apl_options_save( $options ); + + //wp_redirect( 'edit.php?post_type=apl_post_list&page=apl_settings' ); + wp_redirect( 'admin.php?page=apl_settings' ); + //wp_die(); + exit(); + } + + /** + * Settings Page AJAX Hooks + * + * Add AJAX hooks for Settings Page. + * + * @uses 'wp_ajax_{name}' + */ + public function add_settings_ajax_hooks() { + add_action( 'wp_ajax_apl_settings_export', array( $this, 'ajax_settings_export' ) ); + add_action( 'wp_ajax_apl_export', 'apl_export' ); + + add_action( 'wp_ajax_apl_settings_import', array( $this, 'ajax_settings_import' ) ); + add_action( 'wp_ajax_apl_import', 'apl_import' ); + } + + /** + * AJAX Settings Page Export + * + * Handles the AJAX call for exporting data. + */ + public function ajax_settings_export() { + check_ajax_referer( 'apl_settings_export' ); + + $rtn_data = array( + 'action' => 'apl_export', + '_ajax_nonce' => wp_create_nonce( 'apl_export' ), + ); + + $tmp_filename = 'file_export_name'; + if ( isset( $_POST['filename'] ) ) { + $tmp_filename = filter_input( INPUT_POST, 'filename', FILTER_SANITIZE_STRING ); + } + $rtn_data['filename'] = $tmp_filename; + + $export_data = array( + 'version' => APL_VERSION, + 'apl_post_list_arr' => array(), + 'apl_design_arr' => array(), + ); + + $args = array( + 'post_type' => 'apl_post_list', + 'post_status' => 'publish', + //'field' => 'slug', + 'posts_per_page' => -1, + ); + $apl_post_lists = new WP_Query( $args ); + + foreach ( $apl_post_lists->posts as $post_obj ) { + $apl_post_list = new APL_Post_List( $post_obj->post_name ); + $apl_design = new APL_Design( $apl_post_list->pl_apl_design ); + + $export_data['apl_post_list_arr'][] = $apl_post_list->slug; + $export_data['apl_design_arr'][] = $apl_design->slug; + } + + update_option( 'apl_export_data', $export_data ); + + echo json_encode( $rtn_data ); + + wp_die(); + } + + /** + * AJAX Settings Import + * + * @since 0.4.0 + * + * @uses add_settings_ajax_hooks(). + * @uses wp_ajax_apl_settings_import. + */ + public function ajax_settings_import() { + check_ajax_referer( 'apl_settings_import' ); + + $raw_content = array(); + $i = 0; + while ( isset( $_FILES[ 'file_' . $i ] ) ) { + $file_arr = $_FILES[ 'file_' . $i ]; + $file_content = file_get_contents( $file_arr['tmp_name'] ); + $raw_content[] = json_decode( $file_content ); + $i++; + } + + $imported_content = array(); + foreach ( $raw_content as $v1_content ) { + $update_items = array(); + if ( isset( $v1_content->version ) ) { + $version = $v1_content->version; + } else { + return new WP_Error( 'apl_admin', __( 'Version number is not present in imported file.', 'advanced-post-list' ) ); + die(); + } + if ( isset( $v1_content->presetDbObj ) ) { + $update_items['preset_db'] = $v1_content->presetDbObj; + } + if ( isset( $v1_content->apl_post_list_arr ) ) { + $update_items['apl_post_list_arr'] = $v1_content->apl_post_list_arr; + } + if ( isset( $v1_content->apl_design_arr ) ) { + $update_items['apl_design_arr'] = $v1_content->apl_design_arr; + } + + $updater = new APL_Updater( $version, $update_items, 'OBJECT' ); + + $imported_content[] = array( + 'apl_post_list_arr' => $updater->apl_post_list_arr, + 'apl_design_arr' => $updater->apl_design_arr, + ); + + } + + $overwrite_apl_post_list = array(); + $overwrite_apl_design = array(); + + $data_overwrite_post_list = array(); + $data_overwrite_design = array(); + + foreach ( $imported_content as $v1_content ) { + // POST LISTS. + foreach ( $v1_content['apl_post_list_arr'] as $v2_post_list ) { + $db_post_list = new APL_Post_List( $v2_post_list->slug ); + // Check if Post List (ID) already exists. + if ( 0 !== $db_post_list->id ) { + $overwrite_apl_post_list[] = $v2_post_list; + $data_overwrite_post_list[] = $v2_post_list->slug; + } else { + // Add Variable to Database. + $this->import_process_post_list( $v2_post_list ); + } + } + + // DESIGNS. + foreach ( $v1_content['apl_design_arr'] as $v2_design ) { + $db_design = new APL_Design( $v2_design->slug ); + if ( 0 !== $db_design->id ) { + $overwrite_apl_design[] = $v2_design; + $data_overwrite_design[] = $v2_design->slug; + } else { + // Add Variable to Database. + $this->import_process_design( $v2_design ); + } + } + } + + update_option( 'apl_import_overwrite_post_list', $overwrite_apl_post_list ); + update_option( 'apl_import_overwrite_design', $overwrite_apl_design ); + + $rtn_data = array( + 'action' => 'apl_import', + '_ajax_nonce' => wp_create_nonce( 'apl_import' ), + 'overwrite_post_list' => $data_overwrite_post_list, + 'overwrite_design' => $data_overwrite_design, + ); + + echo json_encode( $rtn_data ); + + die(); + } + + /** + * Process Import for Post Lists + * + * @ignore + * @since 0.4.0 + * + * @param APL_Post_List $apl_post_list + */ + private function import_process_post_list( $apl_post_list ) { + $tmp_apl_post_list = new APL_Post_List( $apl_post_list->slug ); + + $tmp_apl_post_list->title = $apl_post_list->title ?: $tmp_apl_post_list->title; + $tmp_apl_post_list->post_type = $apl_post_list->post_type ? json_decode( json_encode( $apl_post_list->post_type ), true ) : $tmp_apl_post_list->post_type ; + $tmp_apl_post_list->tax_query = $apl_post_list->tax_query ? json_decode( json_encode( $apl_post_list->tax_query ), true ) : $tmp_apl_post_list->tax_query; + $tmp_apl_post_list->post_parent__in = $apl_post_list->post_parent__in ? json_decode( json_encode( $apl_post_list->post_parent__in ), true ) : $tmp_apl_post_list->post_parent__in; + $tmp_apl_post_list->post_parent_dynamic = $apl_post_list->post_parent_dynamic ? json_decode( json_encode( $apl_post_list->post_parent_dynamic ), true ) : $tmp_apl_post_list->post_parent_dynamic; + $tmp_apl_post_list->posts_per_page = $apl_post_list->posts_per_page ?: $tmp_apl_post_list->posts_per_page; + $tmp_apl_post_list->offset = $apl_post_list->offset ?: $tmp_apl_post_list->offset; + $tmp_apl_post_list->order_by = $apl_post_list->order_by ?: $tmp_apl_post_list->order_by; + $tmp_apl_post_list->order = $apl_post_list->order ?: $tmp_apl_post_list->order; + $tmp_apl_post_list->post_status = $apl_post_list->post_status ? json_decode( json_encode( $apl_post_list->post_status ), true ) : $tmp_apl_post_list->post_status; + $tmp_apl_post_list->perm = $apl_post_list->perm ?: $tmp_apl_post_list->perm; + $tmp_apl_post_list->author__bool = $apl_post_list->author__bool ?: $tmp_apl_post_list->author__bool; + $tmp_apl_post_list->author__in = $apl_post_list->author__in ?: $tmp_apl_post_list->author__in; + $tmp_apl_post_list->ignore_sticky_posts = $apl_post_list->ignore_sticky_posts ?: $tmp_apl_post_list->ignore_sticky_posts; + $tmp_apl_post_list->post__not_in = $apl_post_list->post__not_in ?: $tmp_apl_post_list->post__not_in; + $tmp_apl_post_list->pl_exclude_current = $apl_post_list->pl_exclude_current ?: $tmp_apl_post_list->pl_exclude_current; + $tmp_apl_post_list->pl_exclude_dupes = $apl_post_list->pl_exclude_dupes ?: $tmp_apl_post_list->pl_exclude_dupes; + $tmp_apl_post_list->pl_apl_design = $apl_post_list->pl_apl_design ?: $tmp_apl_post_list->pl_apl_design; + + $tmp_apl_post_list->save_post_list(); + } + + /** + * Process Import for Designs + * + * @ignore + * @since 0.4.0 + * + * @param APL_Design $apl_design + */ + private function import_process_design( $apl_design ) { + $tmp_apl_design = new APL_Design( $apl_design->slug ); + + $tmp_apl_design->title = $apl_design->title ?: $tmp_apl_design->title; + $tmp_apl_design->before = $apl_design->before ?: $tmp_apl_design->before; + $tmp_apl_design->content = $apl_design->content ?: $tmp_apl_design->content; + $tmp_apl_design->after = $apl_design->after ?: $tmp_apl_design->after; + $tmp_apl_design->empty = $apl_design->empty ?: $tmp_apl_design->empty; + + $tmp_apl_design->save_design(); + } + + /** + * Process Post List Form + * + * Gathers data from the Post List edit page. + * + * @ignore + * @since 0.4.0 + * @access private + * + * @see $this->save_post_list() + * + * @param int $post_id Old post ID. + * @param WP_Post $post Current Post object. + */ + private function post_list_process( $post_id, $post ) { + $old_post = get_post( $post_id ); + $apl_post_list = new APL_Post_List( $old_post->post_name ); + + // post_type[0,1,2] = 'any' || 'none' || array(); CANNOT USE 'any' IN ARRAY. + // tax_query[pt1,pt2,pt3] = array( empty ) || array( query ). + // post_parent__in. + // post_parent_dynamic. + $tmp_post_type = array(); + $tmp_tax_query = array(); + + $tmp_post_parent__in = array(); + $tmp_post_parent_dynamic = array(); + + $post_type_names = apl_get_display_post_types(); + $post_type_names = array_merge( array( 'any' => __( 'Any / All', 'advanced-post-list' ) ), $post_type_names ); + foreach ( $post_type_names as $k_pt_slug => $v_pt_title ) { + // POST TYPES (ACTIVE). + if ( isset( $_POST[ 'apl_toggle-' . $k_pt_slug ] ) ) { + $tmp_tax_query[ $k_pt_slug ] = array(); + + // If 'Any / All' is toggled, then treat 'any' differently and skip the rest. + if ( 'any' === $k_pt_slug ) { + // 'any' TAXONOMY. + $tmp_post_type[] = 'any'; + + if ( isset( $_POST['apl_multiselect_taxonomies-any'] ) ) { + $tmp_tax_query[ $k_pt_slug ] = $this->post_list_process_tax_query( $k_pt_slug ); + } + + break; + } else { + // POST TYPE TAXONOMIES. + $tmp_post_type[] = array( $k_pt_slug ); + + if ( isset( $_POST[ 'apl_multiselect_taxonomies-' . $k_pt_slug ] ) ) { + $tmp_tax_query[ $k_pt_slug ] = $this->post_list_process_tax_query( $k_pt_slug ); + } + + // PAGE PARENTS. + if ( is_post_type_hierarchical( $k_pt_slug ) ) { + + $tmp_post_parent_dynamic[ $k_pt_slug ] = false; + if ( isset( $_POST[ 'apl_page_parent_dynamic-' . $k_pt_slug ] ) ) { + $tmp_post_parent_dynamic[ $k_pt_slug ] = true; + } + + $page_args = array( + 'post_type' => $k_pt_slug, + 'posts_per_page' => -1, + 'order' => 'DESC', + 'orderby' => 'id', + ); + $page_query = new WP_Query( $page_args ); + while ( $page_query->have_posts() ) { + $page_query->the_post(); + + if ( isset( $_POST[ 'apl_page_parent-' . $k_pt_slug . '-' . $page_query->post->ID ] ) ) { + if ( ! isset( $tmp_post_parent__in[ $k_pt_slug ] ) ) { + $tmp_post_parent__in[ $k_pt_slug ] = array(); + } + $tmp_post_parent__in[ $k_pt_slug ][] = $page_query->post->ID; + } + } + wp_reset_postdata(); + } + }// End if(). + }// End if(). + }// End foreach(). + $apl_post_list->post_type = $tmp_post_type; + $apl_post_list->tax_query = $tmp_tax_query; + + $apl_post_list->post_parent__in = $tmp_post_parent__in; + $apl_post_list->post_parent_dynamic = $tmp_post_parent_dynamic; + + // posts_per_page. + $tmp_posts_per_page = 5; + if ( isset( $_POST['apl_posts_per_page'] ) ) { + $p_posts_per_page = filter_input( INPUT_POST, 'apl_posts_per_page', FILTER_SANITIZE_NUMBER_INT ); + $tmp_posts_per_page = intval( $p_posts_per_page ); + } + $apl_post_list->posts_per_page = $tmp_posts_per_page; + + // offset. + $tmp_offset = 5; + if ( isset( $_POST['apl_offset'] ) ) { + $p_offset = filter_input( INPUT_POST, 'apl_offset', FILTER_SANITIZE_NUMBER_INT ); + $tmp_offset = intval( $p_offset ); + } + $apl_post_list->offset = $tmp_offset; + + // order_by. + // order. + $tmp_order_by = 'none'; + $tmp_order = 'DESC'; + if ( isset( $_POST['apl_order_by'] ) ) { + $order_by = filter_input( INPUT_POST, 'apl_order_by', FILTER_SANITIZE_STRING ); + $tmp_order_by = $order_by; + + if ( 'none' !== $order_by && isset( $_POST['apl_order'] ) ) { + $order = filter_input( INPUT_POST, 'apl_order', FILTER_SANITIZE_STRING ); + $tmp_order = $order; + } + } + $apl_post_list->order_by = $tmp_order_by; + $apl_post_list->order = $tmp_order; + + // post_status = array ( 'public', 'publish' ). + $tmp_post_status = 'any'; + if ( isset( $_POST['apl_post_status_1'] ) ) { + $p_post_status_1 = array_map( 'sanitize_key', $_POST['apl_post_status_1'] ); + + $p_post_status_2 = array(); + if ( 'none' === $p_post_status_1[0] || 'any' === $p_post_status_1[0] ) { + $tmp_post_status = $p_post_status_1[0]; + } else { + // add 'public' &| 'private' + if ( isset( $_POST['apl_post_status_2'] ) ) { + $p_post_status_2 = array_map( 'sanitize_key', $_POST['apl_post_status_2'] ); + } + $tmp_post_status = array_merge( $p_post_status_1, $p_post_status_2 ); + } + } + $apl_post_list->post_status = $tmp_post_status; + + // perm. + $tmp_perm = 'none'; + if ( isset( $_POST['apl_perm'] ) ) { + $tmp_perm = filter_input( INPUT_POST, 'apl_perm', FILTER_SANITIZE_STRING ); + } + $apl_post_list->perm = $tmp_perm; + + // author_in = (boolean). + // author = array( ). + $tmp_author__bool = 'none'; + $tmp_author__in = array(); + if ( isset( $_POST['apl_author__bool'] ) ) { + $tmp_author__bool = filter_input( INPUT_POST, 'apl_author__bool', FILTER_SANITIZE_STRING ); + + if ( 'none' !== $tmp_author__bool && isset( $_POST['apl_author__in'] ) ) { + $tmp_author__in = array_map( 'intval', $_POST['apl_author__in'] ); + } + } + $apl_post_list->author__bool = $tmp_author__bool; + $apl_post_list->author__in = $tmp_author__in; + + // post__not_in. + $tmp_post__not_in = array(); + if ( isset( $_POST['apl_post__not_in'] ) ) { + $p_post__not_in = filter_input( INPUT_POST, 'apl_post__not_in', FILTER_SANITIZE_STRING ); + if ( ! empty( $p_post__not_in ) ) { + $tmp_post__not_in = array_map( 'absint', explode( ',', $p_post__not_in ) ); + } + } + $apl_post_list->post__not_in = $tmp_post__not_in; + + // ignore_stick_posts. + $tmp_ignore_sticky_posts = true; + if ( isset( $_POST['apl_sticky_posts'] ) ) { + $p_ignore_sticky_posts = filter_input( INPUT_POST, 'apl_sticky_posts', FILTER_SANITIZE_STRING ); + $tmp_ignore_sticky_posts = false; + } + $apl_post_list->ignore_sticky_posts = $tmp_ignore_sticky_posts; + + // pl_exclude_current. + $tmp_pl_exclude_current = false; + if ( isset( $_POST['apl_pl_exclude_current'] ) ) { + $p_pl_exclude_current = filter_input( INPUT_POST, 'apl_pl_exclude_current', FILTER_SANITIZE_STRING ); + $tmp_pl_exclude_current = true; + } + $apl_post_list->pl_exclude_current = $tmp_pl_exclude_current; + + // pl_exclude_dupes. + $tmp_pl_exclude_dupes = false; + if ( isset( $_POST['apl_pl_exclude_dupes'] ) ) { + $p_pl_exclude_dupes = filter_input( INPUT_POST, 'apl_pl_exclude_dupes', FILTER_SANITIZE_STRING ); + $tmp_pl_exclude_dupes = true; + } + $apl_post_list->pl_exclude_dupes = $tmp_pl_exclude_dupes; + + $new_design_slug = ''; + if ( ! empty( $post->post_name ) ) { + $new_design_slug = $post->post_name; + } + + $apl_post_list->pl_apl_design = $this->post_list_process_apl_design( $apl_post_list->pl_apl_design, $new_design_slug ); + } + + /** + * Process Tax Query + * + * Processes the taxonomies and returns 'multiple arrays' simular to $args['tax_query']. + * + * @ignore + * @since 0.4.0 + * @access private + * + * @see WP_Query Args + * @link https://gist.github.com/luetkemj/2023628 + * + * @param string $post_type Post Type slug. + * @return array Tax_Query used in WP_Query Args. + */ + private function post_list_process_tax_query( $post_type ) { + // Get the list of active taxonomies. + $p_taxonomies = array_map( 'sanitize_key', $_POST[ 'apl_multiselect_taxonomies-' . $post_type ] ); + $tmp_tax_query = array(); + $tmp_req_tax = 'OR'; + foreach ( $p_taxonomies as $v1_taxonomy ) { + // Check 'require' as an active checkbox. + // Else process other checkboxes. + if ( 'require' === $v1_taxonomy ) { + $tmp_req_tax = 'AND'; + } else { + // Check Require Terms. + $tmp_terms_req = 'IN'; + if ( isset( $_POST[ 'apl_terms_req-' . $post_type . '-' . $v1_taxonomy ] ) ) { + $tmp_terms_req = 'AND'; + } + + // Check Dynamic Terms. + $tmp_terms_dynamic = false; + if ( isset( $_POST[ 'apl_terms_dynamic-' . $post_type . '-' . $v1_taxonomy ] ) ) { + $tmp_terms_dynamic = true; + } + + // TERM LOOP. + $arg_terms = array( + 'taxonomy' => $v1_taxonomy, + 'hide_empty' => false, + ); + $terms = get_terms( $arg_terms ); + $tmp_terms = array(); + $tmp_terms_slug = array(); + foreach ( $terms as $v2_term_obj ) { + // Check 'any' term, and if set, skip other terms. break; + if ( isset( $_POST[ 'apl_term-' . $post_type . '-' . $v1_taxonomy . '-any' ] ) ) { + // No reason to have dynamic true with 'any'; fallback method. + $tmp_terms[] = 0; + $tmp_terms_dynamic = false; + break; + } elseif ( isset( $_POST[ 'apl_term-' . $post_type . '-' . $v1_taxonomy . '-' . $v2_term_obj->term_id ] ) ) { + $tmp_terms[] = $v2_term_obj->term_id; + $tmp_terms_slug[ $v2_term_obj->term_id ] = $v2_term_obj->slug; + } + } + + $tmp_tax_query[] = array( + 'taxonomy' => $v1_taxonomy, + 'field' => 'id', // Or 'slug'. + 'terms' => $tmp_terms, + 'include_children' => false, + 'operator' => $tmp_terms_req, // 'IN' | 'AND' | --'NOT IN'-- + + //'apl_terms_req' = $tmp_terms_req; + 'apl_terms_slug' => $tmp_terms_slug, + 'apl_terms_dynamic' => $tmp_terms_dynamic, + ); + }// End if(). + } // End foreach(). + $tmp_tax_query['relation'] = $tmp_req_tax; + + return $tmp_tax_query; + } + + /** + * Process Design Meta Box + * + * Processes the incoming data to APL Designs. + * + * @ignore + * @since 0.4.0 + * @access private + * + * @param string $apl_design_slug Current active slug. + * @param string $new_design_slug New slug relative to $this->pl_apl_design. + * @return string Slug used in $this->pl_apl_design. + */ + private function post_list_process_apl_design( $apl_design_slug, $new_design_slug ) { + $apl_design = new APL_Design( $apl_design_slug ); + + // SLUG / KEY. + //if ( $new_design_slug !== $apl_design_slug && '-design' !== $new_design_slug ) { + if ( $new_design_slug !== $apl_design_slug ) { + $apl_design->title = $new_design_slug; + $apl_design->slug = sanitize_title_with_dashes( $new_design_slug ); + } + + // BEFORE. + $tmp_apl_design_before = ''; + if ( isset( $_POST['apl_before'] ) ) { + $tmp_apl_design_before = filter_input( INPUT_POST, 'apl_before', FILTER_UNSAFE_RAW ); + } + $apl_design->before = $tmp_apl_design_before; + + // CONTENT. + $tmp_apl_design_content = ''; + if ( isset( $_POST['apl_content'] ) ) { + $tmp_apl_design_content = filter_input( INPUT_POST, 'apl_content', FILTER_UNSAFE_RAW ); + } + $apl_design->content = $tmp_apl_design_content; + + // AFTER. + $tmp_apl_design_after = ''; + if ( isset( $_POST['apl_after'] ) ) { + $tmp_apl_design_after = filter_input( INPUT_POST, 'apl_after', FILTER_UNSAFE_RAW ); + } + $apl_design->after = $tmp_apl_design_after; + + // EMPTY MESSAGE. + $tmp_apl_design_empty = ''; + if ( isset( $_POST['apl_empty_enable'] ) && isset( $_POST['apl_empty_message'] ) ) { + $tmp_apl_design_empty = filter_input( INPUT_POST, 'apl_empty_message', FILTER_UNSAFE_RAW ); + } + $apl_design->empty = $tmp_apl_design_empty; + + // Save APL_Design. + $apl_design->save_design(); + + // SLUG/KEY. + $rtn_apl_design_slug = ''; + $rtn_apl_design_slug = $apl_design->slug; + + return $rtn_apl_design_slug; + } + + /** + * Process APL Design Class + * + * @since 0.4.0 + * @access private + * + * @param int $post_id Contains the ID of the post type. + * @param WP_Post $post New Post Data content to save/update. + */ + private function design_process( $post_id, $post ) { + $old_post = get_post( $post_id ); + $apl_design = new APL_Design( $old_post->post_name ); + + // BEFORE. + $tmp_apl_design_before = ''; + if ( isset( $_POST['apl_before'] ) ) { + $tmp_apl_design_before = filter_input( INPUT_POST, 'apl_before', FILTER_UNSAFE_RAW ); + } + $apl_design->before = $tmp_apl_design_before; + + // CONTENT. + $tmp_apl_design_content = ''; + if ( isset( $_POST['apl_content'] ) ) { + $tmp_apl_design_content = filter_input( INPUT_POST, 'apl_content', FILTER_UNSAFE_RAW ); + } + $apl_design->content = $tmp_apl_design_content; + + // AFTER. + $tmp_apl_design_after = ''; + if ( isset( $_POST['apl_after'] ) ) { + $tmp_apl_design_after = filter_input( INPUT_POST, 'apl_after', FILTER_UNSAFE_RAW ); + } + $apl_design->after = $tmp_apl_design_after; + + // EMPTY MESSAGE. + $tmp_apl_design_empty = ''; + if ( isset( $_POST['apl_empty_enable'] ) && isset( $_POST['apl_empty_message'] ) ) { + $tmp_apl_design_empty = filter_input( INPUT_POST, 'apl_empty_message', FILTER_UNSAFE_RAW ); + } + $apl_design->empty = $tmp_apl_design_empty; + } + + /* + * ************************************************************************* + * **** PRIVATE FUNCTIONS ************************************************** + * ************************************************************************* + */ + + /** + * Get Post Type & Taxonomies + * + * Gets and returns an array of Post_Types => Taxonomies. + * + * @ignore + * @since 0.4.0 + * @access private + * + * @return array Post_Type = > Name, Taxonomy Array. + */ + private function get_post_tax() { + $rtn_post_tax = array(); + + $post_types = apl_get_display_post_types(); + + // Add to rtn {post_type} => {array( taxonomies )}. + $rtn_post_tax['any']['name'] = __( 'Any / All', 'advanced-post-list' ); + $taxonomy_names = get_taxonomies( '', 'names' ); + foreach ( $taxonomy_names as $name ) { + $rtn_post_tax['any']['tax_arr'][] = $name; + } + + foreach ( $post_types as $k_slug => $v_name ) { + $rtn_post_tax[ $k_slug ]['name'] = $v_name; + $rtn_post_tax[ $k_slug ]['tax_arr'] = get_object_taxonomies( $k_slug, 'names' ); + } + + // Return Post_Tax. + return $rtn_post_tax; + } + + /** + * Get Taxonomies & Terms + * + * Gets and returns an array of Taxonomies => Terms. + * + * @see get_terms() + * @link https://developer.wordpress.org/reference/functions/get_terms/ + * + * @ignore + * @since 0.4.0 + * @access private + * + * @return array Taxonomy => Term. + */ + private function get_tax_terms() { + $rtn_tax_terms = array(); + + // Get Taxonomy Names. + $taxonomy_names = get_taxonomies( '', 'names' ); + + // Loop foreach taxonomy. Get terms, and foreach term add to taxonomy. + foreach ( $taxonomy_names as $taxonomy ) { + $args = array( + 'taxonomy' => $taxonomy, + 'hide_empty' => false, + ); + $terms = get_terms( $args ); + + // Set slug. + $rtn_tax_terms[ $taxonomy ] = array(); + foreach ( $terms as $term ) { + $rtn_tax_terms[ $taxonomy ][] = $term->term_id; + } + } + + // Return Tax_Terms. + return $rtn_tax_terms; + } + + /** + * Get Post Types to Display + * + * Displays a *valid* list of post types that also aren't on the global ignore list. + * + * @ignore + * @since 0.4.0 + * @access private + * + * @see $this->_ignore_post_types. + * + * @return array List of Post Types. + */ + private function get_display_post_types() { + $rtn_post_types = array(); + + $post_type_objs = get_post_types( '', 'objects' ); + // Remove ignored Post Types. + $ignore_post_types = apl_get_display_post_types(); + foreach ( $ignore_post_types as $value ) { + unset( $post_type_objs[ $value ] ); + } + + foreach ( $post_type_objs as $key => $value ) { + $rtn_post_types[ $key ] = $value->labels->singular_name; + } + + return $rtn_post_types; + } + +} diff --git a/admin/css/admin.css b/admin/css/admin.css index 64b7c5d..7575095 100644 --- a/admin/css/admin.css +++ b/admin/css/admin.css @@ -1,74 +1,248 @@ - .txtHeader - { - width:610px; - position:absolute; - left:290px; - } - -/*OPTION SECTION ON APL_admin PAGE*/ -#containerOptions { - height: 416px; - max-width: 800px; - min-width: 720px; -} -#optionsHeader { - margin-bottom: 5px; - width: auto; - min-height: 20px; -} -#optionL { +/** + * APL Admin UI CSS + * + * @package advanced-post-list + * @subpackage APL_Admin + * @subpackage jQuery UI + * @subpackage jQuery UI Multiselect + * @since 0.4.0 + */ + +.ui-tabs-anchor { + padding: .1em 1em !important; +} + +.ui-multiselect-close { + display: none; +} + +.apl-tooltip { + /*text-align: left;*/ +} + +.apl-help { + cursor: help; +} + +.apl-help-icon { + color: #0073aa; +} + +.apl-info-icon:active, +.apl-info-icon:focus, +.apl-info-icon:hover { + color: #0096dd +} +/* + * FILTER META BOX (TOP). + */ + +.apl-filter-box-1 { + display: flex; + margin-bottom: 18px; +} + +.apl-left-minibar { + float: left; + width: 20%; +} + +.apl-filter-post-type {} + +.apl-filter-post-tax-query { + float: left; + width: 80%; +} + +.apl-tabs-post_type-type { + height: 405px; +} + +.apl-tabs-post-type-taxonomies { + height: 300px; +} + +.apl-t-li-post-type { + float: right !important; +} + +.apl-t-li-post-type h5 { + margin: initial; +} + +.apl-chk-req-taxonomies { + border-bottom: 1px solid #23282d +} + +.apl-tabs-post-type-taxonomies > ul { + min-height: 22px; +} + +.apl-t-terms { + overflow-x: hidden !important; +} + +.apl-t-terms label {} + +/* + * FILTER META BOX (BOTTOM). + */ + +.apl-filter-box-2 { + display: flex; + margin-bottom: 18px; +} + +.apl-filter-box-2-left { + float: left; + margin-right: 3%; + width: 57%; +} + +.apl-filter-box-2-right { float: left; - width: 48%; - height: 100%; - margin: 5px; + width: 40%; +} + +.apl-filter-field-left-row { + min-height: 42px; } -#optionR { + +.apl-filter-field-left-row > .apl-list-amount-row { + height: 84px; +} + +.apl-filter-field-right-row { + min-height: 42px; +} + +.apl-filter-field-row-full { + min-height: 42px; +} + +.apl-filter-field-left-row > div:first-child { + float: left; + width: 35%; +} + +.apl-filter-field-left-row > div:nth-child( 2 ) { + float: left; + width: 65%; +} + +.apl-spinner-posts_per_page-wrap { + float: left; + width: 25%; +} + +.apl-spinner-posts_per_page-wrap > span { + width: 100%; +} + +.apl-slider-posts_per_page-wrap { + float: left; + width: 64%; + margin: 6px 0% 6px 6%; +} + +.apl-slider-handle-posts_per_page { + z-index: 0 !important; +} + +.apl-spinner-offset-wrap { + float: left; + width: 25%; +} + +.apl-spinner-offset-wrap > span { + width: 100%; +} + +.apl-slider-offset-wrap { + float: left; + width: 64%; + margin: 6px 0% 6px 6%; +} + +.apl-slider-handle-offset { + z-index: 0 !important; +} + +apl-filter-field-right-row > input { float: right; - width: 48%; - height: 100%; - margin: 5px; } -.optionL-row { - min-height: 26px; + +apl-filter-field-right-row > input:after { + clear: both; +} + +.apl-ui-ms { + display: inline-block; + overflow: hidden; + position: relative; + text-decoration: none; + cursor: pointer; + + padding: 0 !important; +} + +.apl-ui-ms > span.ui-icon { + right: 0.5em; + left: auto; + margin-top: -8px; + position: absolute; + top: 50%; } -.optionR-row { - min-height: 26px; - margin-right: 25px; - margin-top: 9px; + +.apl-ui-ms > span:nth-child(2) { + float: left; + text-align: left; + padding: 0.4em 1.5em 0.4em 1em; + display: block; + line-height: 1.4; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } -#options1 { - width: 335px; - margin-right: 25px; - margin-top: 5px; - margin-bottom: 5px; - margin-left: 5px; + +button.apl-ui-ms-filter-2-row { + width: 48.0% !important; } -#options2 { - width: 335px; - margin-right: 25px; - margin-top: 5px; - margin-bottom: 5px; - margin-left: 5px; + +span.apl-ui-ms-filter-2-row { + width: 47.2% !important; } -.info-icon { - cursor: help; +input.apl-text-exclude-posts { + width: 100%; } -.ui-button-text { - padding: .4em 1em !important; -} -.info_a_link { - cursor: help; - font-size: 75% + +.apl-chkbox-input { + float: right; + margin-top: 5px !important; } /* -.ui-accordion-header { cursor: none; } + * DESIGN META BOX + */ +.apl-design-box-1 { + display: flex; + margin-bottom: 18px; +} -.ui-accordion-header { padding-left: 0 } +.apl-design-column {} +.apl-design-row { + float: left; + width: 100%; +} -.ui-button { margin-left: -1px; } +.apl-design-row > div:first-child { + float: left; + width: 20.3%; +} -.ui-autocomplete-input { margin: 0; padding: 0.48em 0 0.47em 0.45em; } -*/ +.apl-design-row > div:nth-child( 2 ) { + float: left; + width: 79.7%; +} diff --git a/admin/css/jquery.multiselect.css b/admin/css/jquery.multiselect.css index ec4dd82..735fed3 100644 --- a/admin/css/jquery.multiselect.css +++ b/admin/css/jquery.multiselect.css @@ -1,30 +1,26 @@ .ui-multiselect { padding:2px 0 2px 4px; text-align:left } .ui-multiselect span.ui-icon { float:right } -.ui-multiselect-single .ui-multiselect-checkboxes input { position:absolute !important; top: auto !important; left:-9999px; } +.ui-multiselect-single .ui-multiselect-checkboxes input { left:-9999px; position:absolute !important; top: auto !important; } .ui-multiselect-single .ui-multiselect-checkboxes label { padding:5px !important } -.ui-multiselect-header { margin-bottom:3px; padding:3px 0 3px 4px } +.ui-multiselect-header { margin-bottom:3px; padding:3px 0 3px 4px; } .ui-multiselect-header ul { font-size:0.9em } -.ui-multiselect-header ul li { float:left; padding:0 10px 0 0 } -.ui-multiselect-header a { text-decoration:none } -.ui-multiselect-header a:hover { text-decoration:underline } -.ui-multiselect-header span.ui-icon { float:left } -.ui-multiselect-header li.ui-multiselect-close { float:right; text-align:right; padding-right:0 } +.ui-multiselect-header ul li { float:left; padding:0 10px 0 0; } +.ui-multiselect-header a { text-decoration:none; } +.ui-multiselect-header a:hover { text-decoration:underline; } +.ui-multiselect-header span.ui-icon { float:left; } +.ui-multiselect-header .ui-multiselect-close { float:right; padding-right:0; text-align:right; } -.ui-multiselect-menu { display:none; padding:3px; position:absolute; z-index:10000; text-align: left } -.ui-multiselect-checkboxes { position:relative /* fixes bug in IE6/7 */; overflow-y:auto } -.ui-multiselect-checkboxes label { cursor:default; display:block; border:1px solid transparent; padding:3px 1px } +.ui-multiselect-menu { display:none; padding:3px; position:absolute; text-align: left; } +.ui-multiselect-checkboxes { overflow-y:auto; position:relative; } +.ui-multiselect-checkboxes label { border:1px solid transparent; cursor:default; display:block; padding:3px 1px; } .ui-multiselect-checkboxes label input { position:relative; top:1px } -.ui-multiselect-checkboxes li { clear:both; font-size:0.9em; padding-right:3px } -.ui-multiselect-checkboxes li.ui-multiselect-optgroup-label { text-align:center; font-weight:bold; border-bottom:1px solid } -.ui-multiselect-checkboxes li.ui-multiselect-optgroup-label a { display:block; padding:3px; margin:1px 0; text-decoration:none } - -/* remove label borders in IE6 because IE6 does not support transparency */ -* html .ui-multiselect-checkboxes label { border:none } - +.ui-multiselect-checkboxes label img { height: 30px; vertical-align: middle; padding-right: 3px;} +.ui-multiselect-checkboxes li { clear:both; font-size:0.9em; list-style: none; padding-right:3px; } +.ui-multiselect-checkboxes .ui-multiselect-optgroup { padding: 3px; } +.ui-multiselect-columns { display: inline-block; vertical-align: top; } +.ui-multiselect-checkboxes .ui-multiselect-optgroup a { border-bottom:1px solid; cursor: pointer; display:block; font-weight:bold; margin:1px 0; padding:3px; text-align:center; text-decoration:none; } @media print{ - .ui-multiselect-menu {display: none;} - + .ui-multiselect-menu {display: none;} } - diff --git a/admin/css/settings.css b/admin/css/settings.css new file mode 100644 index 0000000..5fa4a85 --- /dev/null +++ b/admin/css/settings.css @@ -0,0 +1,44 @@ +/** + * APL Admin UI CSS + * + * @package advanced-post-list + * @subpackage APL_Admin + * @since 0.4.0 + */ + +/* TOOLTIPS */ +.apl-help { + cursor: help; +} + +.apl-help-icon { + color: #0073aa; +} + +/* SETTINGS */ +.apl-settings-row { + display: flex; + clear: left; + min-height: 18px; + margin-bottom: 18px; +} + +.apl-settings-row > div { + float: left; +} + +.apl-row-first-cell { + width: 36%; +} + +.apl-cell-1of2 { + width: 64%; +} +.apl-settings-row > input { + float: left; +} + +.apl-settings-row > textarea { + margin-left: 36%; + width: 64%; +} diff --git a/admin/export.php b/admin/export.php index 2c9efb9..9b96b64 100644 --- a/admin/export.php +++ b/admin/export.php @@ -1,15 +1,54 @@ $export_data['version'], + 'apl_post_list_arr' => array(), + 'apl_design_arr' => array(), + ); + + foreach ( $export_data['apl_post_list_arr'] as $apl_post_list_slug ) { + $post_list = new APL_Post_List( $apl_post_list_slug ); + + if ( ! empty( $post_list->id ) ) { + $output_data['apl_post_list_arr'][] = $post_list; + } + } + foreach ( $export_data['apl_design_arr'] as $apl_design_slug ) { + $design = new APL_Design( $apl_design_slug ); + + if ( ! empty( $design->id ) ) { + $output_data['apl_design_arr'][] = $design; + } + } + + header( 'Content-type: application/json' ); + header( 'Content-Disposition: attachment; filename="' . $_GET['filename'] . '.json"' ); + + // OLD METHOD. + //echo trim( json_encode( $outputFileData ) ); + echo json_encode( $output_data ); + wp_die(); } -?> \ No newline at end of file diff --git a/admin/import.php b/admin/import.php index 995a896..4e49a39 100644 --- a/admin/import.php +++ b/admin/import.php @@ -1,34 +1,107 @@ _preset_db as $tmp_preset_name => $tmp_preset_value) - { - //ADD MISSING - if (!isset($presetDbObj->_preset_db->$tmp_preset_name)) - { - $presetDbObj->_preset_db->$tmp_preset_name = $tmp_preset_value; - } - //ADD TO CONFIRM OVERWRITE LIST {OBJECT} - else - { - foreach ($overwrite_list as $value) - { - if ($tmp_preset_name == $value) - { - $presetDbObj->_preset_db->$tmp_preset_name = $tmp_preset_value; - break; - } - } - } - } - $presetDbObj->options_save_db; - delete_option('APL_TMP_import_presetDbObj'); +/** + * APL Import from File(s) + * + * Used to catch any files that need to be overwritten. + * + * @since 0.3.0 + * @since 0.4.0 Changed to Post Data. + */ +function apl_import() { + check_ajax_referer( 'apl_import' ); + + $tmp_post_list = get_option( 'apl_import_overwrite_post_list' ); + $tmp_design = get_option( 'apl_import_overwrite_design' ); + + if ( isset( $_GET['post_list_overwrite'] ) ) { + $tmp_post_list_slugs = explode( ',', $_GET['post_list_overwrite'] ); + + foreach ( $tmp_post_list_slugs as $v1_pt_slug ) { + foreach ( $tmp_post_list as $k2_index => $v2_post_list_import ) { + if ( $v1_pt_slug === $v2_post_list_import->slug ) { + $apl_post_list = new APL_Post_List( $v2_post_list_import->slug ); + + $apl_post_list->title = $v2_post_list_import->title ?: $apl_post_list->title; + $apl_post_list->post_type = $v2_post_list_import->post_type ? json_decode( json_encode( $apl_post_list->post_type ), true ) : $apl_post_list->post_type ; + $apl_post_list->tax_query = $v2_post_list_import->tax_query ? json_decode( json_encode( $apl_post_list->tax_query ), true ) : $apl_post_list->tax_query; + $apl_post_list->post_parent__in = $v2_post_list_import->post_parent__in ? json_decode( json_encode( $apl_post_list->post_parent__in ), true ) : $apl_post_list->post_parent__in; + $apl_post_list->post_parent_dynamic = $v2_post_list_import->post_parent_dynamic ? json_decode( json_encode( $apl_post_list->post_parent_dynamic ), true ) : $apl_post_list->post_parent_dynamic; + $apl_post_list->posts_per_page = $v2_post_list_import->posts_per_page ?: $apl_post_list->posts_per_page; + $apl_post_list->offset = $v2_post_list_import->offset ?: $apl_post_list->offset; + $apl_post_list->order_by = $v2_post_list_import->order_by ?: $apl_post_list->order_by; + $apl_post_list->order = $v2_post_list_import->order ?: $apl_post_list->order; + $apl_post_list->post_status = $v2_post_list_import->post_status ? json_decode( json_encode( $apl_post_list->post_status ), true ): $apl_post_list->post_status; + $apl_post_list->perm = $v2_post_list_import->perm ?: $apl_post_list->perm; + $apl_post_list->author__bool = $v2_post_list_import->author__bool ?: $apl_post_list->author__bool; + $apl_post_list->author__in = $v2_post_list_import->author__in ?: $apl_post_list->author__in; + $apl_post_list->ignore_sticky_posts = $v2_post_list_import->ignore_sticky_posts ?: $apl_post_list->ignore_sticky_posts; + $apl_post_list->post__not_in = $v2_post_list_import->post__not_in ?: $apl_post_list->post__not_in; + $apl_post_list->pl_exclude_current = $v2_post_list_import->pl_exclude_current ?: $apl_post_list->pl_exclude_current; + $apl_post_list->pl_exclude_dupes = $v2_post_list_import->pl_exclude_dupes ?: $apl_post_list->pl_exclude_dupes; + $apl_post_list->pl_apl_design = $v2_post_list_import->pl_apl_design ?: $apl_post_list->pl_apl_design; + + $apl_post_list->save_post_list(); + unset( $tmp_post_list[ $k2_index ] ); + } + } + } + } + if ( isset( $_GET['post_list_overwrite'] ) ) { + $tmp_post_list_slugs = explode( ',', $_GET['post_list_overwrite'] ); + + foreach ( $tmp_post_list_slugs as $v1_d_slug ) { + foreach ( $tmp_design as $v2_design_import ) { + if ( $v1_d_slug === $v2_design_import->slug ) { + + $apl_design = new APL_Design( $v2_design_import->slug ); + + $apl_design->title = $v2_design_import->title ?: $apl_design->title; + $apl_design->before = $v2_design_import->before ?: $apl_design->before; + $apl_design->content = $v2_design_import->content ?: $apl_design->content; + $apl_design->after = $v2_design_import->after ?: $apl_design->after; + $apl_design->empty = $v2_design_import->empty ?: $apl_design->empty; + + $apl_design->save_design(); + } + } + } + } + + /* POSSIBLE CONCEPT FOR SELECTING DESIGNS */ + //if ( isset( $_GET['design_overwrite'] ) ) { + // $tmp_design_slugs = explode( ',', $_GET['design_overwrite'] ); + // + // foreach ( $tmp_design_slugs as $v1_d_slug ) { + // foreach ( $tmp_design as $v2_design_import ) { + // if ( $v1_d_slug === $v2_design_import->slug ) { + // + // $apl_design = new APL_Design( $v2_design_import->slug ); + // + // $apl_design->title = $v2_design_import->title ?: $apl_design->title; + // $apl_design->before = $v2_design_import->before ?: $apl_design->before; + // $apl_design->content = $v2_design_import->content ?: $apl_design->content; + // $apl_design->after = $v2_design_import->after ?: $apl_design->after; + // $apl_design->empty = $v2_design_import->empty ?: $apl_design->empty; + // + // $apl_design->save_design(); + // } + // } + // } + //} + + delete_option( 'apl_import_overwrite_post_list' ); + delete_option( 'apl_import_overwrite_design' ); } -?> + diff --git a/admin/js/admin-ui.js b/admin/js/admin-ui.js index 7d7c237..45ec41f 100644 --- a/admin/js/admin-ui.js +++ b/admin/js/admin-ui.js @@ -1,441 +1,648 @@ -jQuery(document).ready(function($) -{ - // postTax: is the Post Type and Taxonomy structure - var post_types = apl_admin_ui_settings.post_types; - var postTax = apl_admin_ui_settings.postTax; - var taxTerms = apl_admin_ui_settings.taxTerms; - // postTax_parent_selector: show which Post Types are heirarchical - var postTax_parent_selector = apl_admin_ui_settings.postTax_parent_selector; - - - // Sets everything up inside the accordian divider - // -Parent Selector (MultiSelect) - // -Category & Tag UI Tabs - // -3 Checks (Possibly move to APL-admin.js) - for (var post_type_name in postTax) - { - - //Sets the MultiSelect Post Parent Selector - $("#slctParentSelector-" + post_type_name).multiselect({ - noneSelectedText: "Select Parent", - selectedText: "# of # pages selected", - selectedList: 2, - height: 192, - buttonWidth:230, - menuWidth:275, - - //Function for when an option is clicked and update/refreshed the element - click: function(event, ui) - { - - for (var post_type in post_types) - { - // GET/INIT Parent IDs array - var parentIDs = $("#slctParentSelector-" + post_type).val(); - if (parentIDs === null) - { - parentIDs = new Array(); - } - // INIT Temp Array to replace Parent Selector - var tmp_array = new Array(); - - //Going to add clicked value - if (ui.checked === true) - { - tmp_array = parentIDs; - //Add the value at the end of the Array - tmp_array[parentIDs.length] = ui.value; - } - //Going to withhold clicked value - else - { - var i = 0; - for (var parent_index in parentIDs) - { - //Prevent the value from being copied to the array - if (parentIDs[parent_index] !== ui.value) - { - tmp_array[i] = parentIDs[parent_index]; - i++; - } - } - } - $("#slctParentSelector-" + post_type).val(tmp_array); - $("#slctParentSelector-" + post_type).multiselect('refresh'); - } - }//END of click function - });//END of multiselect - - //Disables the Parent Selector/MultiSelect if the Post Type is non-heirarchical/posts - if (postTax_parent_selector[post_type_name]['hierarchical'] === false) - { - $("#slctParentSelector-" + post_type_name).multiselect("disable"); - } - - //$( "#chkReq-" + post_type_name ).button(); - //$( "#chkIncld-" + post_type_name ).button(); - - // Sets up the Categories UI Tabs - $("#tabs-" + post_type_name + '-cats').tabs(); - $('#tabs-' + post_type_name + '-cats').children().each(function(index, domEle) - { - var div_size = $(this).parent().height(); - - if (index !== 0) - { - var tab_size = $(this).parent().children().first().height(); - var change = div_size - tab_size; - - var domPadding = $('#' + domEle.id).outerHeight() - $('#' + domEle.id).height(); - - change -= (domPadding); - $(domEle).height(change); - - - } - }); - - // Sets up the Tags UI Tabs - $("#tabs-" + post_type_name + '-tags').tabs(); - $('#tabs-' + post_type_name + '-tags').children().each(function(index, domEle) - { - var div_size = $(this).parent().height(); - - if (index !== 0) - { - var tab_size = $(this).parent().children().first().height(); - var change = div_size - tab_size; - - var domPadding = $('#' + domEle.id).outerHeight() - $('#' + domEle.id).height(); - - change -= (domPadding); - $(domEle).height(change); - } - }); - - - for (var taxonomy in postTax[post_type_name].taxonomies) - { - - $('#chkReqTerms-' + post_type_name + '-' + taxonomy).click(function(){ - if (this.checked === true) - { - var name = this.name; - var name_explode = name.split("-"); - $('#chkTerm-' + name_explode[1] + '-' + name_explode[2] + '-0').attr('checked', false); - } - }); - - $('#chkIncldTerms-' + post_type_name + '-' + taxonomy).click(function(){ - if (this.checked === true) - { - var name = this.name; - var name_explode = name.split("-"); - $('#chkTerm-' + name_explode[1] + '-' + name_explode[2] + '-0').attr('checked', false); - } - }); - - $('#chkTerm-' + post_type_name + '-' + taxonomy + '-0').click(function(){ - if (this.checked === true) - { - var name = this.name; - var name_explode = name.split("-"); - $('#chkReqTerms-' + name_explode[1] + '-' + name_explode[2]).attr('checked', false); - $('#chkIncldTerms-' + name_explode[1] + '-' + name_explode[2]).attr('checked', false); - for (var term_index in taxTerms[name_explode[2]].terms) - { - $('#' + name_explode[0] + '-' + name_explode[1] + '-' + name_explode[2] + '-' + taxTerms[name_explode[2]].terms[term_index]).attr('checked', false); - - } - } - }); - - for (var term_index in taxTerms[taxonomy].terms) - { - - $('#chkTerm-' + post_type_name + '-' + taxonomy + '-' + taxTerms[taxonomy].terms[term_index]).click(function(){ - if (this.checked === true) - { - var name = this.name; - var name_explode = name.split("-"); - $('#' + name_explode[0] + '-' + name_explode[1] + '-' + name_explode[2] + '-0').attr('checked', false); - } - }); - } - } - }//END of foreach post_type - - $("#cboPostVisibility").multiselect({ - header: false, - noneSelectedText: "1 Req.", - selectedList: 1, - //buttonWidth: 96, Does NOTHING now. - minWidth: 96, - menuWidth: 128, - height: 69, - - click:function(event, ui) - { - var elemCbo = $("#cboPostVisibility").val(); - if (elemCbo === null) - { - elemCbo = new Array(); - } - var tmp_array = new Array(); - - if (ui.checked === true) - { - tmp_array = elemCbo; - //Add the value at the end of the Array - tmp_array[elemCbo.length] = ui.value; - } - else - { - var i = 0; - for (var elemCbo_index in elemCbo) - { - //Prevent the value from being copied to the array - if (elemCbo[elemCbo_index] !== ui.value) - { - tmp_array[i] = elemCbo[elemCbo_index]; - i++; - } - } - } - - $("#cboPostVisibility").val(tmp_array); - $("#cboPostVisibility").multiselect('refresh'); - - - }, - - //Prevents an empty value to be stored. At least 1 option must be selected - close:function(event,ui) - { - var values = $("#cboPostVisibility").val(); - if (values === null) - { - var default_value = new Array('public'); - $("#cboPostVisibility").val(default_value); - $("#cboPostVisibility").multiselect('refresh'); - } - } - }); - $("#cboPostStatus").multiselect({ - header: false, - noneSelectedText: "Any", - selectedList: 1, - //buttonWidth: 128, - minWidth: 128, - menuWidth: 160, - - click:function(event, ui) - { - var elemCbo = $("#cboPostStatus").val(); - if (elemCbo === null) - { - elemCbo = new Array(); - } - var tmp_array = new Array(); - - if (ui.checked === true) - { - tmp_array = elemCbo; - //Add the value at the end of the Array - tmp_array[elemCbo.length] = ui.value; - } - else - { - var i = 0; - for (var elemCbo_index in elemCbo) - { - //Prevent the value from being copied to the array - if (elemCbo[elemCbo_index] !== ui.value) - { - tmp_array[i] = elemCbo[elemCbo_index]; - i++; - } - } - } - - $("#cboPostStatus").val(tmp_array); - $("#cboPostStatus").multiselect('refresh'); - - - } - }); - - $("#slctAuthorOperator").multiselect({ - multiple: false, - header: false, - selectedList: 1, - //buttonWidth: 96, - minWidth: 96, - menuWidth: 128, - height:96, - click:function(event, ui){ - - if (ui.value === "none") - { - var newArr = new Array(); - $("#cboAuthorIDs").val(newArr); - $("#cboAuthorIDs").multiselect('refresh'); - $("#cboAuthorIDs").multiselect("disable"); - } - else - { - $("#cboAuthorIDs").multiselect("enable"); - } - $("#slctAuthorOperator").val(ui.value); - $("#slctAuthorOperator").multiselect('refresh'); - } - }); - $("#cboAuthorIDs").multiselect({ - header: false, - noneSelectedText: '-None-', - selectedList: 1, - //buttonWidth: 128, - minWidth: 128, - menuWidth: 256, - - click:function(event, ui) - { - var elemCbo = $("#cboAuthorIDs").val(); - if (elemCbo === null) - { - elemCbo = new Array(); - } - var tmp_array = new Array(); - - if (ui.checked === true) - { - tmp_array = elemCbo; - //Add the value at the end of the Array - tmp_array[elemCbo.length] = ui.value; - } - else - { - var i = 0; - for (var elemCbo_index in elemCbo) - { - //Prevent the value from being copied to the array - if (elemCbo[elemCbo_index] !== ui.value) - { - tmp_array[i] = elemCbo[elemCbo_index]; - i++; - } - } - } - - $("#cboAuthorIDs").val(tmp_array); - $("#cboAuthorIDs").multiselect('refresh'); - } - }); - $("#cboAuthorIDs").multiselect("disable"); - - $("#slctUserPerm").multiselect({ - multiple: false, - header: false, - noneSelectedText: false, - selectedList: 1, - //buttonWidth: 96, - minWidth: 96, - menuWidth: 128, - height: 69, - - click:function(event, ui) - { - $("#slctUserPerm").val(ui.value); - $("#slctUserPerm").multiselect('refresh'); - } - }); - - //(ELEMENT - Exclude Post IDs) - - //(ELEMENT - List Amount) - - $("#slctOrderBy").multiselect({ - multiple: false, - header: false, - noneSelectedText: "Select an Option", - selectedList: 1, - //buttonWidth: 132, - minWidth: 132, - menuWidth: 192, - - click:function(event, ui) - { - $("#slctOrderBy").val(ui.value); - $("#slctOrderBy").multiselect('refresh'); - } - }); - $("#slctOrder").multiselect({ - multiple: false, - header: false, - noneSelectedText: "Select an Option", - selectedList: 1, - //buttonWidth: 128, - minWidth: 128, - menuWidth: 160, - height: 69, - - click:function(event, ui) - { - $("#slctOrder").val(ui.value); - $("#slctOrder").multiselect('refresh'); - } - }); - - //(ELEMENT - Ignore Sticky Posts) - - //(ELEMENT - Exclude Current Post) - - //(ELEMENT - Exclude Duplicates from Current Post) - - - $("#btnSavePreset").button(); - $("#btnSaveSettings").button(); - $("#btnExport").button(); - $("#btnImport").button(); - $("#btnRestorePreset").button(); - $("#info10").click(function() - { - $("#d10").dialog({ width: 640, height: 480 }); - }); - $("#info11").click(function() - { - $("#d11").dialog({ width: 640, height: 480 }); - }); - $("#info12").click(function() - { - $("#d12").dialog({ width: 640}); - }); - $("#info13").click(function() - { - $("#d13").dialog({ width: 640, height: 480 }); - }); - $("#info14").click(function() - { - $("#d14").dialog({ width: 640 }); - }); - $("#info15").click(function() - { - $("#d15").dialog({ width: 640 }); - }); - $("#info16").click(function() - { - $("#d16").dialog({ width: 640 }); - }); - $("#divCustomPostTaxonomyContent").accordion({ - icons: false - }); - $("#divCustomPostTaxonomyContent").children().each(function(index, domEle) - { - - if(domEle.localName === 'div') - { - $(domEle).height(356); - } - }); - -}); \ No newline at end of file +/** + * Admin UI JavaScript + * + * @summary Admin JavaScript / jQuery for UI design and conditional logic. + * + * @since 0.4.0 + * @package APL_Admin + * @requires jQuery + * @requires jQuery UI + * @requires jQuery UI Multiselect + */ + +( function($) { + var post_tax = apl_admin_ui_local.post_tax; + var tax_terms = apl_admin_ui_local.tax_terms; + var trans = apl_admin_ui_local.trans; + + init_chkbox_post_type_toggle_tabs(); + init_tabs_post_type_taxonomies(); + init_multiselect_post_type_taxonomies(); + init_chkbox_terms(); + init_spinner_amount(); + init_slider_amount(); + init_selectmenu_order_by(); + init_selectmenu_order(); + init_selectmenu_author_operator(); + init_multiselect_author_ids(); + init_multiselect_post_status_1(); + init_multiselect_post_status_2(); + init_selectmenu_perm(); + + init_spinner_offset(); + init_slider_offset(); + + init_textarea_empty_message(); + + apl_init_tooltips(); + apl_init_dialogs(); + + /** + * Initialize Toggling Tabs with Checkbox + * + * @since 0.4.0 + * @returns {undefined} + */ + function init_chkbox_post_type_toggle_tabs() { + $.each( post_tax, function( k_post_type_slug, v_taxonomy_arr ) { + // On Change/Click Hide or unhide sections + $( '#apl-toggle-' + k_post_type_slug ).change( function() { + if ( $( this ).is( ':checked' ) ) { + if ( 'any' !== k_post_type_slug ) { + $( '#apl-filter-' + k_post_type_slug ).show(); + + $.each( v_taxonomy_arr.tax_arr, function( k2_tax_index, v2_tax_slug ) { + var target_div = '#apl-t-div-' + k_post_type_slug + '-' + v2_tax_slug; + $( target_div ).show(); + return false; + }); + + if ( $( '#apl-toggle-any' ).is( ':checked' ) ) { + $( '#apl-toggle-any' ).prop( 'checked', false ); + $( '#apl-filter-any' ).hide(); + } + } else { + $( this ).prop( 'checked', false ); + } + } else { // Unchecked + $( '#apl-filter-' + k_post_type_slug ).hide(); + + $( '#apl-toggle-any' ).prop( 'checked', true ); + $( '#apl-filter-any' ).show(); + $.each( post_tax, function( k2_post_type_slug, v2_taxonomy_arr ) { + if ( 'any' !== k2_post_type_slug && $( '#apl-toggle-' + k2_post_type_slug ).is( ':checked' ) ) { + $( '#apl-toggle-any' ).prop( 'checked', false ); + $( '#apl-filter-any' ).hide(); + } + }); + } + + $( '#apl-tabs-any-type' ).tabs( 'refresh' ); + $( '#apl-tabs-any-taxonomies' ).tabs( 'refresh' ); + $( '#apl-tabs-' + k_post_type_slug + '-type' ).tabs( 'refresh' ); + $( '#apl-tabs-' + k_post_type_slug + '-taxonomies' ).tabs( 'refresh' ); + });// End of .change(). + });// End of .each(). + } + + /** + * Initialize Post Type Taxonomy Tabs + * + * @since 0.4.0 + * + * @returns {undefined} + */ + function init_tabs_post_type_taxonomies () { + $.each( post_tax, function( k_post_type_slug, v_taxonomy_arr ) { + $( '#apl-tabs-' + k_post_type_slug + '-taxonomies' ).tabs({ + heightStyle: "fill", + create: function(event, ui) { + // MANUALLY HIDE ALL AND SHOW SELECTED. + var opts = $( '#apl-multiselect-' + k_post_type_slug ).children(); + $.each( opts, function( k_tax_index, v_tax_ele ) { + // Hide panel. + var opt_tax = $( v_tax_ele ).val(); + if ( 'require' !== opt_tax ) { + $( '#apl-t-div-' + k_post_type_slug + '-' + opt_tax ).hide(); + + // If selected, unhide. + var selected = $( v_tax_ele ).prop( 'selected' ); + if ( selected ) { + $( '#apl-t-div-' + k_post_type_slug + '-' + opt_tax ).show(); + } + } + }); + var option_index = $( '#apl-multiselect-' + k_post_type_slug + ' option:selected' ).index(); + if ( 0 === option_index ) { + option_index = $( '#apl-multiselect-' + k_post_type_slug + ' option' ).next( ':selected' ).index(); + } + if ( -1 !== option_index ) { + // -1 since req checkbox isn't a tab. + $( '#apl-tabs-' + k_post_type_slug + '-taxonomies' ).tabs( 'option', 'active', ( option_index - 1 ) ); + } + $( '#apl-tabs-' + k_post_type_slug + '-taxonomies' ).tabs( 'refresh' ); + } + }); + + $( '#apl-tabs-' + k_post_type_slug + '-type' ).tabs({ + heightStyle: "fill", + create: function(event, ui) { + //console.log('foobar'); + } + }); + });// End of .each(). + } + + /** + * Initialize Multiselect with Post Type Taxonomy Selector + * + * @since 0.4.0 + * + * @returns {undefined} + */ + function init_multiselect_post_type_taxonomies() { + $.each( post_tax, function( k_pt_slug, v_tax_arr ) { + //var elem = '#apl_chk_req_taxonomies-' + k_pt_slug; + //var help_attr_title1 = $( elem ).attr('title'); + //elem = 'option.apl-chk-req-taxonomies'; + //var help_attr_title2 = $( elem ).attr( 'title' ); + + $( '#apl-multiselect-' + k_pt_slug ).multiselect({ + header: false, + noneSelectedText: trans.tax_noneSelectedText, + selectedText: trans.tax_selectedText, + selectedList: 2, + height: 150, + minWidth:333, + menuWidth:333, + + click: function( event, ui ) { + if ( 'require' === ui.value ) { + return; + } + var target_tab = '#apl-t-li-' + k_pt_slug + '-' + ui.value; + var target_div = '#apl-t-div-' + k_pt_slug + '-' + ui.value; + + var option_index = $( '#apl-multiselect-' + k_pt_slug + ' > option[value="' + ui.value + '"]' ).index(); + + if ( true == ui.checked ) { + $( '#apl-multiselect-' + k_pt_slug + ' option[value="' + ui.value + '"]' ).prop( 'selected', true ); + $( target_tab ).show(); + $( target_div ).show(); + + // TODO - ADD FOCUS / ACTIVE. + // -1 since req checkbox isn't a tab. + $( '#apl-tabs-' + k_pt_slug + '-taxonomies' ).tabs( 'option', 'active', ( option_index - 1 ) ); + + $( '#apl-tabs-' + k_pt_slug + '-taxonomies' ).tabs( 'refresh' ); + } else { + $( '#apl-multiselect-' + k_pt_slug + ' option[value="' + ui.value + '"]' ).prop( 'selected', false ); + $( target_tab ).hide(); + $( target_div ).hide(); + + // TODO - CHANGE FOCUS / ACTIVE. + option_index = $( '#apl-multiselect-' + k_pt_slug + ' option:selected' ).index(); + if ( 0 === option_index ) { + option_index = $( '#apl-multiselect-' + k_pt_slug + ' option' ).next( ':selected' ).index(); + } + if ( -1 !== option_index ) { + // -1 since req checkbox isn't a tab. + $( '#apl-tabs-' + k_pt_slug + '-taxonomies' ).tabs( 'option', 'active', ( option_index - 1 ) ); + } + + $( '#apl-tabs-' + k_pt_slug + '-taxonomies' ).tabs( 'refresh' ); + $( target_div ).hide(); + } + } + }); + + //$( 'li.apl-chk-req-taxonomies' ).attr( 'title', help_attr_title2 ); + + $( '#apl-multiselect-' + k_pt_slug ).multiselect( 'refresh' ); + }); + } + + /** + * Initialized Checkbox Term Events + * + * @since 0.4.0 + * + * @returns {undefined} + */ + function init_chkbox_terms() { + $.each( post_tax, function( k1_pt_slug, v1_pt_value ) { + $.each( v1_pt_value.tax_arr, function( k2_index, v2_tax_slug ) { + //apl_chk_terms_req-XXX-YYY + $( '#apl_chk_terms_req-' + k1_pt_slug + '-' + v2_tax_slug ).change( function( event ) { + // There may be no need. + }); + + //apl_chk_terms_dynamic-XXX-YYY + $( '#apl_chk_terms_dynamic-' + k1_pt_slug + '-' + v2_tax_slug ).change( function( event ) { + if ( this.checked ) { + if ( $( '#term-' + k1_pt_slug + '-' + v2_tax_slug + '-any' ).prop( 'checked' ) ) { + $( this ).prop( 'checked', false ); + } + } else { + // Nothing + } + }); + + //term-any-category-any + // 'Any' TERM CHANGE. + $( '#term-' + k1_pt_slug + '-' + v2_tax_slug + '-any' ).change( function( event ) { + if ( this.checked ) { + $( '#apl_chk_terms_dynamic-' + k1_pt_slug + '-' + v2_tax_slug ).prop( 'checked', false ); + $.each( tax_terms[ v2_tax_slug ], function( k3_index, v3_term_id ) { + var t1_input = '#term-' + k1_pt_slug + '-' + v2_tax_slug + '-' + v3_term_id; + $( t1_input ).prop( 'checked', false ); + }); + } else { + $( this ).prop( 'checked', true ); + } + }); + + var init_term_checked = false; + + $.each( tax_terms[ v2_tax_slug ], function( k3_index, v3_term_id ) { + //term-XX-YY-ZZ + var t1_input = '#term-' + k1_pt_slug + '-' + v2_tax_slug + '-' + v3_term_id; + + if ( $( t1_input ).prop( 'checked' ) ) { + init_term_checked = true; + } + + // TERMS CHANGE. + // term-any-category-TERM_ID. + $( t1_input ).change( function( event ) { + if ( this.checked ) { + $( '#term-' + k1_pt_slug + '-' + v2_tax_slug + '-any' ).prop( 'checked', false ); + } else { // unchecked + var other_checked = false; + $.each( tax_terms[ v2_tax_slug ], function( k4_index, v4_term_id ) { + var t2_input = '#term-' + k1_pt_slug + '-' + v2_tax_slug + '-' + v4_term_id; + if ( $( t2_input ).prop( 'checked' ) && t1_input !== t2_input ) { + other_checked = true; + } + }); + + // Add checked to 'any' + if ( ! other_checked ) { + var t2_input_any = '#term-' + k1_pt_slug + '-' + v2_tax_slug + '-any'; + $( t2_input_any ).prop( 'checked', true ); + } + } + });// End terms .change(). + });// End tax_terms[post_type]. + + if ( ! init_term_checked ) { + $( '#term-' + k1_pt_slug + '-' + v2_tax_slug + '-any' ).prop( 'checked', true ); + } + }); + }); + } + + /** + * Initialize List Amount Spinner + * + * @since 0.4.0 + * + * @returns {undefined} + */ + function init_spinner_amount() { + $( '#apl_spinner_posts_per_page' ).spinner({ + disabled: false, + min: -1, + max:9999, + + change: function( event, ui ) { + $( '#apl_slider_handle_posts_per_page' ).text( ui.value ); + $( '#apl_slider_posts_per_page' ).val( ui.value ); + }, + spin: function( event, ui ) { + $( '#apl_slider_handle_posts_per_page' ).text( ui.value ); + $( '#apl_slider_posts_per_page' ).slider( 'value', ui.value ); + } + }); + } + + /** + * Initialize List Amount Slider + * + * @since 0.4.0 + * + * @returns {undefined} + */ + function init_slider_amount() { + $( '#apl_slider_posts_per_page' ).slider({ + value: $( '#apl_spinner_posts_per_page' ).spinner( 'value' ), + min: -1, + max: 100, + + create: function() { + $( '#apl_slider_handle_posts_per_page' ).text( $( this ).slider( 'value' ) ); + }, + slide: function( event, ui ) { + $( '#apl_slider_handle_posts_per_page' ).text( ui.value ); + $( '#apl_spinner_posts_per_page' ).val( ui.value ); + } + }); + } + + /** + * Initialize Order By Selectmenu + * + * @since 0.4.0 + * + * @returns {undefined} + */ + function init_selectmenu_order_by() { + $( '#apl_selectmenu_order_by' ).selectmenu({ + create: function( event, ui ) { + $( '#' + this.id + '-button' ).addClass( 'apl-ui-ms-filter-2-row' ); + }, + change: function( event, ui ) { + if ( 'none' === ui.item.value ) { + $( '#apl_selectmenu_order' ).selectmenu( 'option', 'disabled', true ); + } else { + $( '#apl_selectmenu_order' ).selectmenu( 'option', 'disabled', false ); + } + } + }); + } + + /** + * Initialize Order Selectmenu + * + * @since 0.4.0 + * + * @returns {undefined} + */ + function init_selectmenu_order() { + $( '#apl_selectmenu_order' ).selectmenu({ + + create: function( event, ui ) { + $( '#' + this.id + '-button' ).addClass( 'apl-ui-ms-filter-2-row' ); + if ( 'none' === $( '#apl_selectmenu_order_by' ).find( ':selected' ).val() ) { + $( this ).selectmenu( 'disable' ); + } + } + }); + } + + /** + * Initialize Author Operators Selectmenu + * + * @since 0.4.0 + * + * @returns {undefined} + */ + function init_selectmenu_author_operator() { + $( '#apl_selectmenu_author__bool' ).selectmenu({ + create: function( event, ui ) { + $( '#' + this.id + '-button' ).addClass( 'apl-ui-ms-filter-2-row' ); + }, + change: function( event, ui ) { + if ( 'none' === ui.item.value ) { + $( '#apl_multiselect_author__in' ).multiselect( 'uncheckAll' ); + $( '#apl_multiselect_author__in' ).multiselect( 'disable' ); + } else { + $( '#apl_multiselect_author__in' ).multiselect( 'enable' ); + } + } + }); + } + + /** + * Initialize Author IDs Multiselect + * + * @since 0.4.0 + * + * @returns {undefined} + */ + function init_multiselect_author_ids() { + $( '#apl_multiselect_author__in' ).multiselect({ + classes: 'apl-ui-ms apl-ui-ms-filter-2-row', + disable: true, + header: false, + noneSelectedText: trans.author_ids_noneSelectedText, + selectedText: trans.author_ids_selectedText, + selectedList: 1, + height: 300, + //minWidth:100, + menuWidth:'auto', + + create: function( event, ui ) { + if ( 'none' === $( '#apl_selectmenu_author__bool' ).find( ':selected' ).val() ) { + $( this ).multiselect( 'disable' ); + } + }, + click: function( event, ui ) {} + }); + } + + /** + * Initialize Post Status 1 Multiselect + * + * @since 0.4.0 + * + * @returns {undefined} + */ + function init_multiselect_post_status_1() { + $( '#apl_multiselect_post_status_1' ).multiselect({ + classes: 'apl-ui-ms apl-ui-ms-filter-2-row', + header: false, + noneSelectedText: trans.post_status_1_noneSelectedText, + selectedText: trans.post_status_1_selectedText, + selectedList: 1, + height: 300, + /* minWidth:'45%', // admin.css button.apl-ui-ms-filter-2-row */ + menuWidth:150, + + click: function( event, ui ) { + // Manually update element for logical operations. + $( '#apl_multiselect_post_status_1 option[value="' + ui.value + '"]' ).prop( 'selected', ui.checked ); + + var opts = $( this ).children(); + + // If clicked is 'Any'. + if ( 'none' === ui.value ) { + if ( true === ui.checked ) { + $( opts[ '1' ] ).prop( 'selected', false ); + $( opts[ '2' ] ).prop( 'selected', false ); + $( opts[ '3' ] ).prop( 'selected', false ); + + $( '#apl_multiselect_post_status_2' ).multiselect( 'uncheckAll' ); + $( '#apl_multiselect_post_status_2' ).multiselect( 'disable' ); + } else { + $( opts[ '0' ] ).prop( 'selected', true ); + } + } else if ( 'any' === ui.value ) { + if ( true === ui.checked ) { + $( opts[ '0' ] ).prop( 'selected', false ); + $( opts[ '2' ] ).prop( 'selected', false ); + $( opts[ '3' ] ).prop( 'selected', false ); + + $( '#apl_multiselect_post_status_2' ).multiselect( 'uncheckAll' ); + $( '#apl_multiselect_post_status_2' ).multiselect( 'disable' ); + } else { + $( opts[ '0' ] ).prop( 'selected', true ); + } + } else { + // If others are checked, then uncheck 'Any' and enable Post_Status_2. + if ( true === ui.checked ) { + var opt2_val = $( opts[ '2' ] ).prop( 'selected' ); + var opt3_val = $( opts[ '3' ] ).prop( 'selected' ); + + if ( ! opt2_val || ! opt3_val ) { + $( '#apl_multiselect_post_status_2' ).find( 'option[value="publish"]' ).prop( 'selected', true ); + $( '#apl_multiselect_post_status_2' ).multiselect( 'enable' ); + } + + $( opts[ '0' ] ).prop( 'selected', false ); + $( opts[ '1' ] ).prop( 'selected', false ); + } else { + // If both are unchecked, then check 'Any' and disable Post_Status_2. + var opt2_val = $( opts[ '2' ] ).prop( 'selected' ); + var opt3_val = $( opts[ '3' ] ).prop( 'selected' ); + + if ( ! opt2_val && ! opt3_val ) { + $( opts[ '0' ] ).prop( 'selected', true ); + + $( '#apl_multiselect_post_status_2' ).multiselect( 'uncheckAll' ); + $( '#apl_multiselect_post_status_2' ).multiselect( 'disable' ); + } + } + }// End if(). + + $( '#apl_multiselect_post_status_1' ).multiselect( 'refresh' ); + $( '#apl_multiselect_post_status_2' ).multiselect( 'refresh' ); + } + }); + } + + /** + * Initialize Post Status 2 Multiselect + * + * @since 0.4.0 + * + * @returns {undefined} + */ + function init_multiselect_post_status_2() { + $( '#apl_multiselect_post_status_2' ).multiselect({ + classes: 'apl-ui-ms apl-ui-ms-filter-2-row', + disabled: true, + header: false, + noneSelectedText: trans.post_status_2_noneSelectedText, + selectedText: trans.post_status_2_selectedText, + selectedList: 1, + height: 300, + minWidth:'45%', + menuWidth:150, + + create: function ( event, ui ) { + $( '#apl_multiselect_post_status_1' ).find( ':selected' ).each( function( index, element ) { + if ( 'none' === $( element ).val() || 'any' === $( element ).val() ) { + $( '#apl_multiselect_post_status_2' ).multiselect( 'disable' ); + $( '#apl_multiselect_post_status_2' ).multiselect( 'refresh' ); + } + }); + }, + click: function( event, ui ) {} + }); + } + + /** + * Initialize Perms Selectmenu + * + * @since 0.4.0 + * + * @returns {undefined} + */ + function init_selectmenu_perm() { + $( '#apl_selectmenu_perm' ).selectmenu({ + create: function( event, ui ) { + $( '#' + this.id + '-button' ).addClass( 'apl-ui-ms-filter-2-row' ); + } + }); + } + + /** + * Initialize Offset Spinner + * + * @since 0.4.0 + * + * @returns {undefined} + */ + function init_spinner_offset() { + $( '#apl_spinner_offset' ).spinner({ + disabled: false, + min: 0, + max:9999, + + change: function( event, ui ) { + $( '#apl_slider_handle_offset' ).text( ui.value ); + $( '#apl_slider_offset' ).val( ui.value ); + }, + spin: function( event, ui ) { + $( '#apl_slider_handle_offset' ).text( ui.value ); + $( '#apl_slider_offset' ).slider( 'value', ui.value ); + } + }); + } + + /** + * Initialize Offset Slider + * + * @since 0.4.0 + * + * @returns {undefined} + */ + function init_slider_offset() { + $( '#apl_slider_offset' ).slider({ + value: $( '#apl_spinner_offset' ).spinner( 'value' ), + min: 0, + max: 100, + + create: function() { + $( '#apl_slider_handle_offset' ).text( $( this ).slider( 'value' ) ); + }, + slide: function( event, ui ) { + $( '#apl_slider_handle_offset' ).text( ui.value ); + $( '#apl_spinner_offset' ).val( ui.value ); + } + }); + } + + /** + * Initialize Empty Message Textacrea + * + * @since 0.4.0 + * + * @returns {undefined} + */ + function init_textarea_empty_message() { + $( '#apl_empty_message_enable' ).change( function( event, ui ) { + if ( this.checked ) { + $( '#apl_textarea_empty_message' ).show(); + } else { + $( '#apl_textarea_empty_message' ).hide(); + } + }); + } + + /** + * Initialize Tooltips + * + * @since 0.4.0 + * + * @returns {undefined} + */ + function apl_init_tooltips() { + $( '.apl-tooltip' ).tooltip({ +// content: function( callback ) { +// //callback( $( this ).prop('title').replace( '()', '
' ) ); +// } + content: function( callback ) { + callback( $( this ).prop( 'title' ) ); + } + }); + } + + /** + * Initialize Dialogs + * + * @since 0.4.0 + * + * @returns {undefined} + */ + function apl_init_dialogs() { + $( '#info-shortcodes' ).click( function() { + $( '#d-shortcodes' ).dialog({ + width: '32%', + height: 450 + }); + }); + } + +})(jQuery); diff --git a/admin/js/admin.js b/admin/js/admin.js index 47275eb..ce56ed7 100644 --- a/admin/js/admin.js +++ b/admin/js/admin.js @@ -1,1287 +1,27 @@ -jQuery(document).ready(function($){ - - if( 'undefined' == typeof( apl_admin_settings ) ) - { - return; +/** + * Basic essential functions usually unrelated to UI/UX. + * + * @summary jQuery Functions. + * + * @since 0.4.0 + * @package APL_Admin + * @requires jQuery + * @requires jQuery UI + * @requires jQuery UI Multiselect + */ + +// TODO - Add Load Preset AJAX +// TODO - Add Pagination for list of Page Parents AJAX +jQuery(document).ready( function($) { + /** + * OLD Sets the correct Output + * + * @ignore + * @param {type} preset_name + * @returns {undefined} + */ + function setPHPOutput( preset_name ) { + //$('#presetPHP').html('PHP code: <?php if (method_exists($advanced_post_list, "display_post_list")){echo $advanced_post_list->display_post_list("' + preset_name + '");} ?>'); } - - var plugin_url = apl_admin_settings.plugin_url; - - var savePresetNonce = apl_admin_settings.savePresetNonce; - var deletePresetNonce = apl_admin_settings.deletePresetNonce; - var restorePresetNonce = apl_admin_settings.restorePresetNonce; - var exportNonce = apl_admin_settings.exportNonce; - var importNonce = apl_admin_settings.importNonce; - var saveSettingsNonce = apl_admin_settings.saveSettingsNonce; - - var presetObj = apl_admin_settings.presetDb; - presetObj = JSON.parse(presetObj); - - var postTax = apl_admin_settings.postTax; - //postTax = JSON.parse(postTax); - - var taxTerms = apl_admin_settings.taxTerms; - - - - - function setPHPOutput(preset_name) - { - //$('#presetPHP').html('PHP code: if(function_exists("kalinsPost_show"){kalinsPost_show("' + data.preset_name + '");}'); - - //$('#presetPHP').html('PHP code: <?php if(function_exists("display_post_list")){display_post_list("' + preset_name + '");} ?>'); - $('#presetPHP').html('PHP code: <?php if (method_exists($advanced_post_list, "display_post_list")){echo $advanced_post_list->display_post_list("' + preset_name + '");} ?>'); - } - //build the file table - we build it all in javascript so we can - // simply rebuild it whenever an entry is added through ajax - function buildPresetTable() - { - - function tc(str) - { - return "" + str + ""; - } - - var tableHTML = ""; - - var count = 0; - for(var i in presetObj) - { - var shortcode = '[post_list name="' + i + '"]'; - tableHTML += "" + tc(count) + tc(i) + tc("") + tc("") + tc("") + tc(shortcode) + ""; - count++; - } - - tableHTML += "
#Preset NameLoadDownloadDeleteShortcode
"; - - $('#presetListDiv').html(tableHTML); - - count = 0; - for(j in presetObj) - { - - $('#btnDelete_' + count).attr('presetname', j); - $('#btnDelete_' + count).click(function() - { - if(confirm("Are you sure you want to delete " + $(this).attr('presetname') + "?")) - { - deletePreset($(this).attr('presetname')); - } - }); - $('#btnDelete_' + count).button(); - - $('#btnDownload_' + count).attr('presetname', j); - $('#btnDownload_' + count).click(function() - { - //FIX - REPLACE PHP CODE - var name = $(this).attr('presetname'); - apl_preset_export(name); - //var url = plugin_url + "includes/export.php?presetname=" + name; - //alert(url); - - //window.location = url; - }); - $('#btnDownload_' + count).button(); - - $('#btnLoad_' + count).attr('presetname', j); - $('#btnLoad_' + count).click(function() - { - loadPreset($(this).attr('presetname')); - }); - $('#btnLoad_' + count).button(); - - count++; - } - } - function apl_preset_export(preset_name) - { - var exportData = { - action : 'APL_handler_export', - _ajax_nonce : exportNonce, - export_type : 'preset', - filename : $.trim(preset_name) - }; - - - - //TESTING MODE SWITCH - //formData.append('alpha_mode', 'true'); - jQuery.ajax({ - url: ajaxurl, - type: 'POST', - //cache: false, - //contentType: false, - //processData: false, - - data: exportData, - - beforeSend: function(jqXHR, settings){ - var element = document.getElementById("APL_exportIF"); - if (element != null) - { - element.parentNode.removeChild(element); - } - }, - dataFilter: function(data, type){ - var dataRtn = convert_JSON_data(data); - return dataRtn; - }, - success: function(data, textStatus, jqXHR){ - //console.log("Hooray, it worked!"); - if (data._status != 'success') - { - apl_alert(data._error, (data._status.charAt(0).toUpperCase() + data._status.slice(1))); - } - else - { - var paramStr = ''; - paramStr += '?_ajax_nonce=' + data._ajax_nonce; - paramStr += '&action=' + data.action; - paramStr += '&filename=' + data.filename; - - - var elemIF = document.createElement("iframe"); - elemIF.id = 'APL_exportIF' - elemIF.style.display = "none"; - elemIF.src = ajaxurl + paramStr; - - document.body.appendChild(elemIF); - - //optionsHeader('Exporting Data Successful'); - } - }, - error: function(jqXHR, textStatus, errorThrown){ - alert(errorThrown.stack); - }, - complete: function(jqXHR, textStatus){ - - } - }); - } - //////////////////////////////////////////////////////////////////////////// - //// AJAX FUNCTIONS //////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////// - function deletePreset(id) - { - //alert("deleting: " + id); - - var data = { - action: 'APL_handler_delete_preset', - _ajax_nonce : deletePresetNonce - } - - data.preset_name = id; - - $('#createStatus').html("Deleting preset..."); - - // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php - jQuery.post(ajaxurl, data, function(response) - { - //alert(response); - - var startPosition = response.indexOf("{"); - var responseObjString = response.substr(startPosition, response.lastIndexOf("}") - startPosition + 1); - - var newFileData = JSON.parse(responseObjString); - - /*if(newFileData.status == "success"){ - $('#createStatus').html("Preset deleted successfully."); - }else{ - $('#createStatus').html(response); - }*/ - - presetObj = newFileData;//.preset_arr; - - buildPresetTable(); - - $('#createStatus').html("Preset deleted successfully."); - - }); - } - function loadPreset(id) - { - //////////////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////////////// - $('#divPreview').html(""); - var newValues = presetObj[id]; - $("#txtPresetName").val(id); - - set_postTax(newValues._postTax); - set_parent(newValues._postParents); - - $("#txtDisplayAmount").val(newValues["_listCount"]); - $("#slctOrderBy").val(newValues["_listOrderBy"]); - $('#slctOrderBy').multiselect('refresh'); - $("#slctOrder").val(newValues["_listOrder"]); - $('#slctOrder').multiselect('refresh'); - - var postVisibilityArr = jQuery.makeArray(newValues._postVisibility); - $('#cboPostVisibility').val(postVisibilityArr); - $('#cboPostVisibility').multiselect('refresh'); - var postStatusArr = jQuery.makeArray(newValues._postStatus); - $('#cboPostStatus').val(postStatusArr); - $('#cboPostStatus').multiselect('refresh'); - - $("#slctUserPerm").val(newValues["_userPerm"]);//ADDED //string - $('#slctUserPerm').multiselect('refresh'); - $("#chkIgnoreSticky").attr('checked', newValues["_listIgnoreSticky"]);//ADDED //boolean - $("#chkExcldCurrent").attr('checked', newValues["_listExcludeCurrent"]); //boolean - $("#chkExcldDuplicates").attr('checked', newValues["_listExcludeDuplicates"]);//ADDED //boolean - - var tmpString = ''; - for (var i in newValues["_listExcludePosts"]) - { - if (newValues["_listExcludePosts"][i] != 0) - { - tmpString += newValues["_listExcludePosts"][i]; - if( i < (newValues["_listExcludePosts"].length - 1) ) - { - tmpString += ','; - } - } - - } - $("#txtExcldPosts").val(tmpString);//ADDED //string - - var postAuthorIDs = new Array(); - if (newValues["_postAuthorOperator"] === 'include' || newValues["_postAuthorOperator"] === 'exclude') - { - $("#slctAuthorOperator").val(newValues["_postAuthorOperator"]) - $("#cboAuthorIDs").multiselect("enable"); - - if (newValues["_postAuthorIDs"].length > 0) - { - postAuthorIDs = newValues["_postAuthorIDs"]; - } - $("#cboAuthorIDs").val(postAuthorIDs);//ADDED //array - $('#cboAuthorIDs').multiselect('refresh'); - - - } - else if (newValues["_postAuthorOperator"] === 'none') - { - $("#slctAuthorOperator").val(newValues["_postAuthorOperator"]) - $("#cboAuthorIDs").val(postAuthorIDs); - $("#cboAuthorIDs").multiselect("disable"); - $('#cboAuthorIDs').multiselect('refresh'); - } - else - { - $("#slctAuthorOperator").val('none') - $("#cboAuthorIDs").val(postAuthorIDs); - $("#cboAuthorIDs").multiselect("disable"); - $('#cboAuthorIDs').multiselect('refresh'); - } - $('#slctAuthorOperator').multiselect('refresh'); - - $("#txtExitMsg").val(newValues["_exit"]); - $("#txtBeforeList").val(newValues["_before"]); - $("#txtContent").val(newValues["_content"]); - $("#txtAfterList").val(newValues["_after"]); - - //////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////// - - setPHPOutput(id); - - setNoneHide(); - } - - function set_postTax(post_tax) - { - - reset_postTax(); - for (var post_type_name in post_tax) - { - - for (var taxonomy_name in post_tax[post_type_name]['taxonomies']) - { - $("#chkReqTaxonomy-" + post_type_name + "-" + taxonomy_name).attr('checked', post_tax[post_type_name]['taxonomies'][taxonomy_name]['require_taxonomy']); - $("#chkReqTerms-" + post_type_name + "-" + taxonomy_name).attr('checked', post_tax[post_type_name]['taxonomies'][taxonomy_name]['require_terms']); - $("#chkIncldTerms-" + post_type_name + "-" + taxonomy_name).attr('checked', post_tax[post_type_name]['taxonomies'][taxonomy_name]['include_terms']); - - for (var term in post_tax[post_type_name]['taxonomies'][taxonomy_name]['terms']) - { - $("#chkTerm-" + post_type_name + "-" + taxonomy_name + '-' + post_tax[post_type_name]['taxonomies'][taxonomy_name]['terms'][term]).attr('checked',true) - } - - } - } - } - function reset_postTax() - { - for (var post_type_name in postTax) - { - for (var taxonomy_name in postTax[post_type_name].taxonomies) - { - $("#chkReqTaxonomy-" + post_type_name + "-" + taxonomy_name).attr('checked', false); - $("#chkReqTerms-" + post_type_name + "-" + taxonomy_name).attr('checked', false); - $("#chkIncldTerms-" + post_type_name + "-" + taxonomy_name).attr('checked', false); - - var terms = taxTerms[taxonomy_name].terms; - - $("#chkTerm-" + post_type_name + "-" + taxonomy_name + '-0').attr('checked',false) - for (var term in terms) - { - $("#chkTerm-" + post_type_name + "-" + taxonomy_name + '-' + terms[term]).attr('checked',false) - } - } - } - } - function set_parent(parentArr) - { - reset_parent(); - //parentArr.toArray(); - parentArr = jQuery.makeArray(parentArr); - - for (var post_type_name in postTax) - { - - $("#slctParentSelector-" + post_type_name).val(parentArr); - $("#slctParentSelector-" + post_type_name).multiselect('refresh'); - //$("#slctParentSelector-" + post_type_name).each(object, callback); - - } - - } - function reset_parent() - { - - for (var post_type_name in postTax) - { - $("#slctParentSelector-" + post_type_name).val([]); - $("#slctParentSelector-" + post_type_name).multiselect('refresh'); - - } - - } - - - - //////////////////////////////////////////////////////////////////////////// - //// AJAX BUTTONS ////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////// - $('#btnSavePreset').click(function() - { - if (!save_preset_precheck()) - { - save_preset(); - } - }); - //// RETURN TRUE IF AN EVENT OCCURED - function save_preset_precheck() - { - if (!check_required()) - { - - if (!check_preset_name()) - { - return false; - } - return true; - } - return true; - - } - function check_required() - { - //var event_occured = false; - for (var post_type_name in postTax) - { - var require_taxonomy = new Array(); - for (var taxonomy_name in postTax[post_type_name].taxonomies) - { - require_taxonomy[taxonomy_name] = new Array(); - require_taxonomy[taxonomy_name]['require'] = $("#chkReqTaxonomy-" + post_type_name + "-" + taxonomy_name).is(':checked'); - var require_terms = $("#chkReqTerms-" + post_type_name + "-" + taxonomy_name).is(':checked'); - var include_terms = $("#chkIncldTerms-" + post_type_name + "-" + taxonomy_name).is(':checked'); - require_taxonomy[taxonomy_name]['count'] = 0; - - var terms = taxTerms[taxonomy_name].terms; - for (var term in terms) - { - if ($("#chkTerm-" + post_type_name + "-" + taxonomy_name + '-' + terms[term]).is(':checked')) - { - require_taxonomy[taxonomy_name]['count']++; - } - } - - - if (require_taxonomy[taxonomy_name]['count'] < 2 && require_terms === true && include_terms === false) - { - $( "#d03" ).dialog({ - resizable: false, - height:192, - modal: true, - buttons: { - "Ok": function() - { - $( this ).dialog( "close" ); - } - } - }); - return true; - } - else if (require_taxonomy[taxonomy_name]['count'] < 2 && require_taxonomy[taxonomy_name]['require'] == true && include_terms == false) - { - $( "#d04" ).dialog({ - resizable: false, - height:224, - modal: true, - buttons: { - "Ok": function() - { - $( this ).dialog( "close" ); - } - } - }); - return true; - } - - } - - for(var taxonomy01 in require_taxonomy) - { - if (require_taxonomy[taxonomy01]['require'] == true) - { - var other_taxonomy_used = false; - for(var taxonomy02 in require_taxonomy) - { - if (require_taxonomy[taxonomy02]['count'] > 0 && taxonomy01 != taxonomy02) - { - other_taxonomy_used = true; - } - } - if (other_taxonomy_used == false) - { - - $( "#d05" ).dialog( - { - resizable: false, - height:224, - modal: true, - buttons: - { - "Ok": function() - { - $( this ).dialog( "close" ); - } - } - }); - return true; - - } - } - - } - - } - return false; - } - function check_preset_name() - { - var preset_name = $("#txtPresetName").val(); - if(presetObj[preset_name]) - { - $( "#d01" ).dialog({ - resizable: false, - height:192, - modal: true, - buttons: { - "Save Preset": function() - { - $( this ).dialog( "close" ); - save_preset(); - }, - "Cancel": function() - { - $( this ).dialog( "close" ); - - } - } - }); - return true; - } - else if(preset_name == "") - { - $( "#d02" ).dialog({ - resizable: false, - height:192, - modal: true, - buttons: { - "Ok": function() - { - $( this ).dialog( "close" ); - - } - } - }); - return true; - } - return false; - - } - - function save_preset() - { - var data = { - action: 'APL_handler_save_preset', - _ajax_nonce : savePresetNonce - }; - //css style bug fix - var btn_height = $('#btnSavePreset').height(); - var btn_width = $('#btnSavePreset').width(); - $('#btnSavePreset').html("Saving..."); - $('#btnSavePreset').height(btn_height); - $('#btnSavePreset').width(btn_width); - - data.presetName = $("#txtPresetName").val(); - - - data.postParents = JSON.stringify(get_parent()); - data.postTax = JSON.stringify(get_postTax()); - - - data.count = $("#txtDisplayAmount").val(); - data.orderBy = $("#slctOrderBy").val(); - data.order = $("#slctOrder").val(); - - data.postVisibility = $('#cboPostVisibility').val();//array - data.postVisibility = JSON.stringify(data.postVisibility); - data.postStatus = $("#cboPostStatus").val();//MODIFIED //array - if (data.postStatus === null) - { - data.postStatus = new Array('any'); - } - data.postStatus = JSON.stringify(data.postStatus); - - data.userPerm = $("#slctUserPerm").val();//ADDED //string - data.ignoreSticky = $("#chkIgnoreSticky").is(':checked');//ADDED //boolean - data.excludeCurrent = $("#chkExcldCurrent").is(':checked'); //boolean - data.excludeDuplicates = $("#chkExcldDuplicates").is(':checked');//ADDED //boolean - - data.excludePosts = $("#txtExcldPosts").val();//ADDED //string - needs to be changed to an array and json string - if (data.excludePosts === "") - { - data.excludePosts = new Array(); - } - else - { - data.excludePosts = data.excludePosts.split(","); - } - data.excludePosts = JSON.stringify(data.excludePosts); - - data.authorOperator = $("#slctAuthorOperator").val();//ADDED //string - - data.authorIDs = $("#cboAuthorIDs").val();//ADDED //array - if (data.authorIDs === null) - { - data.authorIDs = new Array(); - } - data.authorIDs = JSON.stringify(data.authorIDs); - - data.exit = $("#txtExitMsg").val(); - data.before = $("#txtBeforeList").val(); - data.content = $("#txtContent").val(); - data.after = $("#txtAfterList").val(); - - - setPHPOutput(data.presetName); - - - - //since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php - jQuery.post(ajaxurl, data, function(response) - { - - //alert(response); - - var startPosition = response.indexOf("{"); - if (startPosition > 10) - { - apl_alert(response, 'Error'); - } - var responseObjString = response.substr(startPosition, response.lastIndexOf("}") - startPosition + 1); - - //alert(responseObjString); - - var newFileData = JSON.parse(responseObjString); - - presetObj = newFileData.preset_arr; - buildPresetTable(); - $('#btnSavePreset').html("Save Preset"); - - if($("#chkShowPreview").is(':checked')) - { - $('#divPreview').html(newFileData.previewOutput); - } - else - { - $('#divPreview').html(""); - } - - - }); - } - - function get_postTax() - { - var rtnObject = new Object(); - var tmp_post_types = new Object(); - for (var post_type_name in postTax) - { - var tmp_taxonomies = new Object(); - var post_type_used = false; - for (var taxonomy_name in postTax[post_type_name].taxonomies) - { - var tmp_terms = new Array(); - var i = 0; - var terms = taxTerms[taxonomy_name].terms; - if ($("#chkTerm-" + post_type_name + "-" + taxonomy_name + '-' + 0).is(':checked')) - { - tmp_terms[i] = 0; - i++; - } - else - { - for (var term in terms) - { - if ($("#chkTerm-" + post_type_name + "-" + taxonomy_name + '-' + terms[term]).is(':checked')) - { - tmp_terms[i] = terms[term]; - i++; - } - } - } - - if (i > 0 || $("#chkIncldTerms-" + post_type_name + "-" + taxonomy_name).is(':checked')) - { - tmp_taxonomies[taxonomy_name] = new Object(); - tmp_taxonomies[taxonomy_name].require_taxonomy = $("#chkReqTaxonomy-" + post_type_name + "-" + taxonomy_name).is(':checked'); - tmp_taxonomies[taxonomy_name].require_terms = $("#chkReqTerms-" + post_type_name + "-" + taxonomy_name).is(':checked'); - tmp_taxonomies[taxonomy_name].include_terms = $("#chkIncldTerms-" + post_type_name + "-" + taxonomy_name).is(':checked'); - tmp_taxonomies[taxonomy_name].terms = tmp_terms; - - post_type_used = true; - } - } - if (post_type_used) - { - tmp_post_types[post_type_name] = new Object(); - - tmp_post_types[post_type_name].taxonomies = tmp_taxonomies; - - } - - } - rtnObject = tmp_post_types; - return rtnObject; - } - function get_parent() - { - //Custom unique array function to remove any duplicates, especially - // the current page setting. - var unique = function(origArr) - { - var newArr = [], - origLen = origArr.length, - found, - x, y; - - for ( x = 0; x < origLen; x++ ) - { - found = undefined; - for ( y = 0; y < newArr.length; y++ ) - { - if ( origArr[x] === newArr[y] ) - { - found = true; - break; - } - } - if ( !found) newArr.push( origArr[x] ); - } - return newArr; - }; - - var parentIDs = new Array(); - var rtnArray = new Array(); - - var i = 0; - for (var post_type_name in postTax) - { - parentIDs = $("#slctParentSelector-" + post_type_name).val(); - - if (parentIDs !== null) - { - for (var j = 0; j < parentIDs.length; j++, i++) - { - rtnArray[i] = parentIDs[j]; - } - } - } - rtnArray = unique(rtnArray); - return rtnArray; - } - - - function optionsHeader(output) - { - $('#optionsHeader').html('' + output + ''); - $('#optionsHeader').fadeOut(5000, function(){ - $('#optionsHeader').show(); - $('#optionsHeader').html('

General Settings

'); - }); - - } - - - $('#btnSaveSettings').click(function(){ - - save_settings(); - - }); - - function save_settings() - { - var data = { - action : 'APL_handler_save_settings', - _ajax_nonce : saveSettingsNonce - } - - var deleteDb = false; - if ($("#rdoDeleteDbTRUE").is(':checked')) - { - deleteDb = true; - } - else if ($("#rdoDeleteDbFALSE").is(':checked')) - { - deleteDb = false; - } - data.deleteDb = deleteDb; - - data.theme = $('#slctUITheme').val(); - - var defaultExit = false; - if ($("#rdoDefaultExitMsgTRUE").is(':checked')) - { - defaultExit = true; - } - else if ($("#rdoDefaultExitMsgFALSE").is(':checked')) - { - defaultExit = false; - } - data.defaultExit = defaultExit; - data.defaultExitMsg = $("#txtDefaultExitMsg").val(); - - - jQuery.post(ajaxurl, data, function(response) - { - var startPosition = response.indexOf("{"); - var responseObjString = response.substr(startPosition, response.lastIndexOf("}") - startPosition + 1); - var newFileData = JSON.parse(responseObjString); - - - optionsHeader('Options Saved'); - loadjscssfile('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/themes/' + newFileData.theme + '/jquery-ui.css', 'css'); - }); - - } - function loadjscssfile(filename, filetype) - { - var fileref; - //if filename is a external JavaScript file - if (filetype === "js") - { - fileref=document.createElement('script'); - fileref.setAttribute("type","text/javascript"); - fileref.setAttribute("src", filename); - } - //if filename is an external CSS file - else if (filetype === "css") - { - fileref = document.createElement("link"); - fileref.setAttribute("rel", "stylesheet"); - fileref.setAttribute("type", "text/css"); - fileref.setAttribute("href", filename); - } - if (typeof fileref !== "undefined") - { - document.getElementsByTagName("head")[0].appendChild(fileref); - } - - } - function check_string_for_errors(input_string) - { - var iChars = "<>:\"/\\|,?*"; - - for (var i = 0; i < input_string.value.length; i++) - { - if (iChars.indexOf(input_string.value.charAt(i)) != -1) - { - apl_alert("

Cannot use (< > : \" / \\ | , ? *).
Please rename your filename.

", "Illegal Characters"); - return true; - } - - } - return false; - } - $('#txtExportFileName').change(function() - { - check_string_for_errors(document.frmExport.txtExportFileName); - }); - - function apl_alert(output_msg, title_msg) - { - if (!title_msg) - title_msg = 'Alert'; - - if (!output_msg) - output_msg = 'No Message to Display.'; - - $("
").html(output_msg).dialog({ - title: title_msg, - resizable: true, - modal: true, - buttons: { - "Ok": function() - { - $( this ).dialog( "close" ); - - } - } - }); - } - - function convert_JSON_data(json_string) - { - //CONVERT RETURN/RESPONSE DATA (dataRtn) - //SYNTAX .substr(start, length) - //SYNTAX .substring(start, end) - var tmpData = $.trim(json_string); - - - //CHECKS DATA FOR ADDITIONAL CONTENT, FOR EX. PHP ERRORS - //TODO ADD SUPPORT OF MULTI LANGUAGES WITH MULTILINGUAL - var cData = tmpData.split("{\"_msg\""); - if (cData[0].indexOf("
\n") != -1 && cData[0].indexOf("") != -1 && cData.length != 1) - { - cData[0] = $.trim(cData[0]); - var eData = cData[0].split("
\n"); - - //DISPLAY EACH PHP ERROR INDIVIDUALLY - //STARTED INDEX AT 1 SINCE eData[0] IS AN EMPTY STRING CREATED BY .split() - for (i = 1; i < eData.length; i++) - { - $("
").html("
" + eData[i]).dialog({ - title: 'PHP Error', - resizable: true, - minWidth: 576, - modal: true, - buttons: { - "Ok": function() - { - $( this ).dialog( "close" ); - } - } - }); - } - return false; - } - - var rtnData = JSON.parse(tmpData.substring(tmpData.indexOf("{\"_msg\""), tmpData.lastIndexOf("}") + 1)); - - return rtnData; - } - - - //////////////////////////////////////////////////////////////////////////// - //// EXPORT //////////////////////////////////////////////////////////////// - $('#frmExport').submit(function(){ - //CHECK USER SIDE - if (apl_export_errors()) - { - return false; - } - apl_db_export(); - return false; - }); - - function apl_export_errors() - { - var var_filename = document.frmExport.txtExportFileName.value; - if (check_string_for_errors(document.frmExport.txtExportFileName)) - { - return true; - } - if (document.frmExport.txtExportFileName.value == "") - { - apl_alert("A filename doesn't exist.\nPlease enter a filename before exporting.", "Filename Required"); - return true; - } - return false; - } - - function apl_db_export() - { - var formData = new FormData(); - formData.append('action', 'APL_handler_export'); - formData.append('_ajax_nonce', exportNonce); - formData.append('export_type', 'database'); - formData.append('filename', $.trim($('#txtExportFileName').val())); - - //TESTING MODE SWITCH - //formData.append('alpha_mode', 'true'); - jQuery.ajax({ - url: ajaxurl, - type: 'POST', - cache: false, - contentType: false, - processData: false, - - data: formData, - - beforeSend: function(jqXHR, settings){ - var a1 = jqXHR; - var a2 = settings; - var element = document.getElementById("APL_exportIF"); - if (element != null) - { - element.parentNode.removeChild(element); - } - }, - dataFilter: function(data, type){ - var dataRtn = convert_JSON_data(data); - return dataRtn; - }, - success: function(data, textStatus, jqXHR){ - if (data._status != 'success') - { - apl_alert(data._error, (data._status.charAt(0).toUpperCase() + data._status.slice(1))); - } - else - { - var paramStr = ''; - paramStr += '?_ajax_nonce=' + data._ajax_nonce; - paramStr += '&action=' + data.action; - paramStr += '&filename=' + data.filename; - - - var elemIF = document.createElement("iframe"); - elemIF.id = 'APL_exportIF' - elemIF.style.display = "none"; - elemIF.src = ajaxurl + paramStr; - - document.body.appendChild(elemIF); - - optionsHeader('Exporting Data Successful'); - } - }, - error: function(jqXHR, textStatus, errorThrown){ - alert(errorThrown.stack); - }, - complete: function(jqXHR, textStatus){ - var a1 = jqXHR; - var a2 = textStatus; - // - } - }); - } - - //////////////////////////////////////////////////////////////////////////// - //// IMPORT //////////////////////////////////////////////////////////////// - $('#frmImport').submit(function(e) - { - e.preventDefault(); - //CHECK USER SIDE - if (apl_import_errors()) - { - return false; - } - apl_import_db(); - return false; - }); - - function apl_import_errors() - { - for (var i = 0; i < document.frmImport.importType.length; i++) - { - if (document.frmImport.importType[i].checked) - { - var importType = document.frmImport.importType[i].value; - } - } - - - if ($('#fileImportData').val() == '' && importType == 'file') - { - alert('No file(s) selected. Please choose a JSON file to upload.'); - return true; - } - if ($('#fileImportData').val() != '') - { - var ext = $('#fileImportData').val().split('.').pop().toLowerCase(); - if($.inArray(ext, ['json']) == -1) - { - alert('Invalid file type. Please choose a JSON file to upload.'); - return true; - } - } - - return false; - } - function apl_import_db() - { - - var formData = new FormData(); - jQuery.each($('#fileImportData')[0].files, function(i, file) { - formData.append('uploadFile-'+i, file); - }); - formData.append('action', 'APL_handler_import'); - formData.append('_ajax_nonce', importNonce); - - var rdoImport = document.frmImport.importType; - for (var i = 0; i < rdoImport.length; i++) - { - if (rdoImport[i].checked) - { - formData.append('import_type', rdoImport[i].value); - } - } - - //TESTING MODE SWITCH - //formData.append('alpha_mode', 'true'); - jQuery.ajax({ - url: ajaxurl, - type: 'POST', - cache: false, - contentType: false, - processData: false, - - data: formData, - - - beforeSend: function(jqXHR, settings){ - var a1 = jqXHR; - var a2 = settings; - var element = document.getElementById("APL_exportIF"); - if (element != null) - { - element.parentNode.removeChild(element); - } - }, - dataFilter: function(data, type){ - var dataRtn = convert_JSON_data(data); - return dataRtn; - }, - success: function(data, textStatus, jqXHR){ - if (data._msg != 'success') - { - apl_alert(data._error, (data._msg.charAt(0).toUpperCase() + data._msg.slice(1))); - } - if ($.isEmptyObject( data.overwrite_preset_db )) - { - presetObj = data._preset_db; - buildPresetTable(); - - var paramStr = ''; - paramStr += '?_ajax_nonce=' + data._ajax_nonce; - paramStr += '&action=' + data.action; - paramStr += '&overwrite=' + ''; - - var elemIF = document.createElement("iframe"); - elemIF.id = 'APL_importIF' - elemIF.style.display = "none"; - elemIF.src = ajaxurl + paramStr; - - document.body.appendChild(elemIF); - - optionsHeader('Importing Data Successful'); - } - else - { - - var overwrite_output = ''; - overwrite_output += '

(All / None) Presets

'; - - overwrite_output += '
'; - for (var preset_key in data.overwrite_preset_db) - { - overwrite_output += ''; - overwrite_output += ''; - overwrite_output += '
'; - } - overwrite_output += '
'; - $('
').html(overwrite_output).dialog({ - stack: false, - title: 'Overwrite Presets', - resizable: true, - height: 256, - minWidth: 352, - maxWidth: 512, - maxHeight: 448, - modal: true, - buttons: { - Next: function() - { - presetObj = data._preset_db; - apl_import_overwrite(data.overwrite_preset_db, data._ajax_nonce, data.action); - buildPresetTable(); - - optionsHeader('Importing Data Successful'); - - $( this ).dialog( "close" ); - var element = document.getElementById("apl_confirm_overwrite"); - element.parentNode.removeChild(element); - }, - Cancel: function() - { - $( this ).dialog( "close" ); - var element = document.getElementById("apl_confirm_overwrite"); - element.parentNode.removeChild(element); - } - }, - open: function(){ - $('#overwrite_select_group_all').click(function(e){ - for (var preset_key in data.overwrite_preset_db) - { - $('#chkGroup_overwrite_preset_' + preset_key).attr('checked', true); - } - }); - $('#overwrite_select_group_none').click(function(e){ - for (var preset_key in data.overwrite_preset_db) - { - $('#chkGroup_overwrite_preset_' + preset_key).attr('checked', false); - } - }); - } - }); - } - }, - error: function(jqXHR, textStatus, errorThrown){ - alert(errorThrown.stack); - }, - complete: function(jqXHR, textStatus){ - var a1 = jqXHR; - var a2 = textStatus; - } - }); - } - - function apl_import_overwrite(overwrite_preset_db, ajax_nonce, action) - { - var overwrite_list = '';//array of preset names parsed by comma - - for (var preset_key in overwrite_preset_db) - { - if ($('#chkGroup_overwrite_preset_' + preset_key).is(':checked')) - { - overwrite_list += preset_key + ','; - presetObj[preset_key] = overwrite_preset_db[preset_key]; - } - } - overwrite_list = overwrite_list.substring(0, overwrite_list.length - 1); - - var paramStr = ''; - paramStr += '?_ajax_nonce=' + ajax_nonce; - paramStr += '&action=' + action; - paramStr += '&overwrite=' + overwrite_list; - - var elemIF = document.createElement("iframe"); - elemIF.id = 'APL_importIF' - elemIF.style.display = "none"; - elemIF.src = ajaxurl + paramStr; - - document.body.appendChild(elemIF); - elemIF.parentNode.removeChild(elemIF); - - } - - //////////////////////////////////////////////////////////////////////////// - //// RESTORE /////////////////////////////////////////////////////////////// - $('#btnRestorePreset').click(function() - { - //alert(data.post_type); - var data = { - action: 'APL_handler_restore_preset', - _ajax_nonce : restorePresetNonce - } - - if(confirm("Are you sure you want to restore all default presets? This will remove any changes you've made to the default presets, but will not delete your custom presets.")) - { - - //$('#createStatus').html("Restoring presets..."); - $('#divPreview').html(""); - - // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php - jQuery.post(ajaxurl, data, function(response) - { - - var startPosition = response.indexOf("{"); - var responseObjString = response.substr(startPosition, response.lastIndexOf("}") - startPosition + 1); - - //alert(responseObjString); - var newFileData = JSON.parse(responseObjString); - - presetObj = newFileData;//.preset_arr; - buildPresetTable(); - //$('#createStatus').html("Preset successfully added."); - optionsHeader('Restoring Default Presets Successful'); - - }); - } - }); - - - $('#postTypeHeader01').click(function(){ - $('#postTypeContent01').slideToggle('slow') - }); - - //////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////// - $('#cboPost_type').change(function() - { - setNoneHide(); - }); - - function setNoneHide(){ - - var postTypeVal = $("#cboPost_type").val() ; - - if(postTypeVal == "none") - { - $('.noneHide').hide(); - $('.noneShow').show(); - $('#createStatus').html("In 'None' mode, the content field will be displayed only once and all shortcodes will refer to the current page."); - } - else - { - $('.noneHide').show(); - $('.noneShow').hide(); - $('#createStatus').html(" "); - } - - if(postTypeVal != "none" && postTypeVal != "post" && postTypeVal != "attachment") - {//if it's a page or custom type, show parent selector - $('#parentSelector').show(); - } - else - { - $('#parentSelector').hide(); - } - } - - buildPresetTable(); - - //$('#outputSpan').hide(); - $('#parentSelector').hide(); - - }); - - - - - - + \ No newline at end of file diff --git a/admin/js/jquery.multiselect.filter.min.js b/admin/js/jquery.multiselect.filter.min.js index b1d6520..fa93068 100644 --- a/admin/js/jquery.multiselect.filter.min.js +++ b/admin/js/jquery.multiselect.filter.min.js @@ -1,6 +1,6 @@ /* jshint forin:true, noarg:true, noempty:true, eqeqeq:true, boss:true, undef:true, curly:true, browser:true, jquery:true */ /* - * jQuery MultiSelect UI Widget Filtering Plugin 1.6pre + * jQuery MultiSelect UI Widget Filtering Plugin 2.0.0 * Copyright (c) 2012 Eric Hynds * * http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/ @@ -13,4 +13,4 @@ * http://www.gnu.org/licenses/gpl.html * */ -(function($){var rEscape=/[\-\[\]{}()*+?.,\\\^$|#\s]/g;function debounce(func,wait,immediate){var timeout;return function(){var context=this,args=arguments;var later=function(){timeout=null;if(!immediate){func.apply(context,args)}};var callNow=immediate&&!timeout;clearTimeout(timeout);timeout=setTimeout(later,wait);if(callNow){func.apply(context,args)}}}$.widget("ech.multiselectfilter",{options:{label:"Filter:",width:null,placeholder:"Enter keywords",autoReset:false,debounceMS:250},_create:function(){var opts=this.options;var elem=$(this.element);var instance=this.instance=elem.data("echMultiselect")||elem.data("multiselect")||elem.data("ech-multiselect");var header=this.header=instance.menu.find(".ui-multiselect-header").addClass("ui-multiselect-hasfilter");var wrapper=this.wrapper=$('
'+(opts.label.length?opts.label:"")+'
").prependTo(this.header);this.inputs=instance.menu.find('input[type="checkbox"], input[type="radio"]');this.input=wrapper.find("input").bind({keydown:function(e){if(e.which===13){e.preventDefault()}},input:$.proxy(debounce(this._handler,opts.debounceMS),this),search:$.proxy(this._handler,this)});this.updateCache();instance._toggleChecked=function(flag,group){var $inputs=group&&group.length?group:this.labels.find("input");var _self=this;var selector=_self._isOpen?":disabled, :hidden":":disabled";$inputs=$inputs.not(selector).each(this._toggleState("checked",flag));this.update();var values={};$inputs.each(function(){values[this.value]=true});this.element.find("option").filter(function(){if(!this.disabled&&values[this.value]){_self._toggleState("selected",flag).call(this)}});if($inputs.length){this.element.trigger("change")}};var doc=$(document).bind("multiselectrefresh."+instance._namespaceID,$.proxy(function(){this.updateCache();this._handler()},this));if(this.options.autoReset){doc.bind("multiselectclose."+instance._namespaceID,$.proxy(this._reset,this))}},_handler:function(e){var term=$.trim(this.input[0].value.toLowerCase()),rows=this.rows,inputs=this.inputs,cache=this.cache;if(!term){rows.show()}else{rows.hide();var regex=new RegExp(term.replace(rEscape,"\\$&"),"gi");this._trigger("filter",e,$.map(cache,function(v,i){if(v.search(regex)!==-1){rows.eq(i).show();return inputs.get(i)}return null}))}this.instance.menu.find(".ui-multiselect-optgroup-label").each(function(){var $this=$(this);var isVisible=$this.nextUntil(".ui-multiselect-optgroup-label").filter(function(){return $.css(this,"display")!=="none"}).length;$this[isVisible?"show":"hide"]()})},_reset:function(){this.input.val("").trigger("keyup")},updateCache:function(){this.rows=this.instance.menu.find(".ui-multiselect-checkboxes li:not(.ui-multiselect-optgroup-label)");this.cache=this.element.children().map(function(){var elem=$(this);if(this.tagName.toLowerCase()==="optgroup"){elem=elem.children()}return elem.map(function(){return this.innerHTML.toLowerCase()}).get()}).get()},widget:function(){return this.wrapper},destroy:function(){$.Widget.prototype.destroy.call(this);this.input.val("").trigger("keyup");this.wrapper.remove()}})})(jQuery); +(function($){var rEscape=/[\-\[\]{}()*+?.,\\\^$|#\s]/g;function debounce(func,wait,immediate){var timeout;return function(){var context=this,args=arguments;var later=function(){timeout=null;if(!immediate){func.apply(context,args)}};var callNow=immediate&&!timeout;clearTimeout(timeout);timeout=setTimeout(later,wait);if(callNow){func.apply(context,args)}}}$.widget("ech.multiselectfilter",{options:{label:"Filter:",width:null,placeholder:"Enter keywords",autoReset:false,debounceMS:250},_create:function(){var opts=this.options;var elem=$(this.element);this.instance=elem.multiselect("instance");this.header=this.instance.menu.find(".ui-multiselect-header").addClass("ui-multiselect-hasfilter");this.input=$("").attr({placeholder:opts.placeholder,type:"search"}).css({width:/\d/.test(opts.width)?opts.width+"px":null}).bind({keydown:function(e){if(e.which===13){e.preventDefault()}else if(e.which===27){elem.multiselect("close");e.preventDefault()}else if(e.which===9&&e.shiftKey){elem.multiselect("close");e.preventDefault()}else if(e.altKey){switch(e.which){case 82:e.preventDefault();$(this).val("").trigger("input","");break;case 65:elem.multiselect("checkAll");break;case 85:elem.multiselect("uncheckAll");break;case 76:elem.multiselect("instance").labels.first().trigger("mouseenter");break}}},input:$.proxy(debounce(this._handler,opts.debounceMS),this),search:$.proxy(this._handler,this)});if(this.options.autoReset){elem.bind("multiselectclose",$.proxy(this._reset,this))}elem.bind("multiselectrefresh",$.proxy(function(){this.updateCache();this._handler()},this));this.wrapper=$("
").addClass("ui-multiselect-filter").text(opts.label).append(this.input).prependTo(this.header);this.inputs=this.instance.menu.find('input[type="checkbox"], input[type="radio"]');this.updateCache();this.instance._toggleChecked=function(flag,group){var $inputs=group&&group.length?group:this.labels.find("input");var _self=this;var selector=_self._isOpen?":disabled, :hidden":":disabled";$inputs=$inputs.not(selector).each(this._toggleState("checked",flag));this.update();var values={};$inputs.each(function(){values[this.value]=true});this.element.find("option").filter(function(){if(!this.disabled&&values[this.value]){_self._toggleState("selected",flag).call(this)}});if($inputs.length){this.element.trigger("change")}}},_handler:function(e){var term=$.trim(this.input[0].value.toLowerCase()),rows=this.rows,inputs=this.inputs,cache=this.cache;var $groups=this.instance.menu.find(".ui-multiselect-optgroup");$groups.show();if(!term){rows.show()}else{rows.hide();var regex=new RegExp(term.replace(rEscape,"\\$&"),"gi");this._trigger("filter",e,$.map(cache,function(v,i){if(v.search(regex)!==-1){rows.eq(i).show();return inputs.get(i)}return null}))}$groups.each(function(){var $this=$(this);if(!$this.children("li:visible").length){$this.hide()}});this.instance._setMenuHeight()},_reset:function(){this.input.val("").trigger("input","")},updateCache:function(){this.rows=this.instance.labels.parent();this.cache=this.element.children().map(function(){var elem=$(this);if(this.tagName.toLowerCase()==="optgroup"){elem=elem.children()}return elem.map(function(){return this.innerHTML.toLowerCase()}).get()}).get()},widget:function(){return this.wrapper},destroy:function(){$.Widget.prototype.destroy.call(this);this.input.val("").trigger("keyup");this.wrapper.remove()}})})(jQuery); diff --git a/admin/js/jquery.multiselect.min.js b/admin/js/jquery.multiselect.min.js index 03646f5..6f62fdd 100644 --- a/admin/js/jquery.multiselect.min.js +++ b/admin/js/jquery.multiselect.min.js @@ -1,13 +1,13 @@ /* jshint forin:true, noarg:true, noempty:true, eqeqeq:true, boss:true, undef:true, curly:true, browser:true, jquery:true */ /* - * jQuery MultiSelect UI Widget 1.17pre + * jQuery MultiSelect UI Widget 2.0.1 * Copyright (c) 2012 Eric Hynds * * http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/ * * Depends: * - jQuery 1.4.2+ - * - jQuery UI 1.8 widget factory + * - jQuery UI 1.11 widget factory * * Optional: * - jQuery UI effects @@ -18,4 +18,4 @@ * http://www.gnu.org/licenses/gpl.html * */ -(function($,undefined){var multiselectID=0;var $doc=$(document);$.widget("ech.multiselect",{options:{header:true,height:175,minWidth:225,classes:"",checkAllText:"Check all",uncheckAllText:"Uncheck all",noneSelectedText:"Select options",selectedText:"# selected",selectedList:0,closeIcon:"ui-icon-circle-close",show:null,hide:null,autoOpen:false,multiple:true,position:{},appendTo:"body",menuWidth:null,selectedListSeparator:", "},_create:function(){var el=this.element;var o=this.options;this.speed=$.fx.speeds._default;this._isOpen=false;this._namespaceID=this.eventNamespace||"multiselect"+multiselectID;var button=(this.button=$('')).addClass("ui-multiselect ui-widget ui-state-default ui-corner-all").addClass(o.classes).attr({title:el.attr("title"),tabIndex:el.attr("tabIndex"),id:el.attr("id")?el.attr("id")+"_ms":null}).prop("aria-haspopup",true).insertAfter(el),buttonlabel=(this.buttonlabel=$("")).html(o.noneSelectedText).appendTo(button),menu=(this.menu=$("
")).addClass("ui-multiselect-menu ui-widget ui-widget-content ui-corner-all").addClass(o.classes).appendTo($(o.appendTo)),header=(this.header=$("
")).addClass("ui-widget-header ui-corner-all ui-multiselect-header ui-helper-clearfix").appendTo(menu),headerLinkContainer=(this.headerLinkContainer=$("
    ")).addClass("ui-helper-reset").html(function(){if(o.header===true){return'
  • '+o.checkAllText+'
  • '+o.uncheckAllText+"
  • "}else if(typeof o.header==="string"){return"
  • "+o.header+"
  • "}else{return""}}).append('
  • ').appendTo(header),checkboxContainer=(this.checkboxContainer=$("
      ")).addClass("ui-multiselect-checkboxes ui-helper-reset").appendTo(menu);this._bindEvents();this.refresh(true);if(!o.multiple){menu.addClass("ui-multiselect-single")}multiselectID++;el.hide()},_init:function(){if(this.options.header===false){this.header.hide()}if(!this.options.multiple){this.headerLinkContainer.find(".ui-multiselect-all, .ui-multiselect-none").hide()}if(this.options.autoOpen){this.open()}if(this.element.is(":disabled")){this.disable()}},refresh:function(init){var inputIdCounter=0;var el=this.element;var o=this.options;var menu=this.menu;var checkboxContainer=this.checkboxContainer;var html="";var $dropdown=$("
        ").addClass("ui-multiselect-checkboxes ui-helper-reset");var id=el.attr("id")||multiselectID++;function makeItem(option,isInOptionGroup){var title=option.title?option.title:null;var value=option.value;var inputID="ui-multiselect-"+multiselectID+"-"+(option.id||id+"-option-"+inputIdCounter++);var isDisabled=option.disabled;var isSelected=option.selected;var labelClasses=["ui-corner-all"];var liClasses=[];if(isDisabled){liClasses.push("ui-multiselect-disabled");labelClasses.push("ui-state-disabled")}if(option.className){liClasses.push(option.className)}if(isSelected&&!o.multiple){labelClasses.push("ui-state-active")}if(isInOptionGroup){liClasses.push("ui-multiselect-optgrp-child")}var $item=$("
      • ").addClass(liClasses.join(" "));var $label=$("
      • ").addClass("ui-multiselect-optgroup-label "+this.className).appendTo($dropdown);var $link=$("").attr("href","#").text(this.getAttribute("label")).appendTo($groupLabel);$this.children().each(function(){var $listItem=makeItem(this,true).appendTo($dropdown)})}else{var $listItem=makeItem(this).appendTo($dropdown)}});this.menu.find(".ui-multiselect-checkboxes").remove();this.menu.append($dropdown);this.labels=menu.find("label");this.inputs=this.labels.children("input");this._setButtonWidth();this._setMenuWidth();this.button[0].defaultValue=this.update();if(!init){this._trigger("refresh")}},update:function(){var o=this.options;var $inputs=this.inputs;var $checked=$inputs.filter(":checked");var numChecked=$checked.length;var value;if(numChecked===0){value=o.noneSelectedText}else{if($.isFunction(o.selectedText)){value=o.selectedText.call(this,numChecked,$inputs.length,$checked.get())}else if(/\d/.test(o.selectedList)&&o.selectedList>0&&numChecked<=o.selectedList){value=$checked.map(function(){return $(this).next().text()}).get().join(o.selectedListSeparator)}else{value=o.selectedText.replace("#",numChecked).replace("#",$inputs.length)}}this._setButtonValue(value);return value},_setButtonValue:function(value){this.buttonlabel.text(value)},_bindEvents:function(){var self=this;var button=this.button;function clickHandler(){self[self._isOpen?"close":"open"]();return false}button.find("span").bind("click.multiselect",clickHandler);button.bind({click:clickHandler,keypress:function(e){switch(e.which){case 27:case 38:case 37:self.close();break;case 39:case 40:self.open();break}},mouseenter:function(){if(!button.hasClass("ui-state-disabled")){$(this).addClass("ui-state-hover")}},mouseleave:function(){$(this).removeClass("ui-state-hover")},focus:function(){if(!button.hasClass("ui-state-disabled")){$(this).addClass("ui-state-focus")}},blur:function(){$(this).removeClass("ui-state-focus")}});this.header.delegate("a","click.multiselect",function(e){if($(this).hasClass("ui-multiselect-close")){self.close()}else{self[$(this).hasClass("ui-multiselect-all")?"checkAll":"uncheckAll"]()}e.preventDefault()});this.menu.delegate("li.ui-multiselect-optgroup-label a","click.multiselect",function(e){e.preventDefault();var $this=$(this);var $inputs=$this.parent().nextUntil(":not(.ui-multiselect-optgrp-child)").find("input:visible:not(:disabled)");var nodes=$inputs.get();var label=$this.parent().text();if(self._trigger("beforeoptgrouptoggle",e,{inputs:nodes,label:label})===false){return}self._toggleChecked($inputs.filter(":checked").length!==$inputs.length,$inputs);self._trigger("optgrouptoggle",e,{inputs:nodes,label:label,checked:nodes[0].checked})}).delegate("label","mouseenter.multiselect",function(){if(!$(this).hasClass("ui-state-disabled")){self.labels.removeClass("ui-state-hover");$(this).addClass("ui-state-hover").find("input").focus()}}).delegate("label","keydown.multiselect",function(e){e.preventDefault();switch(e.which){case 9:case 27:self.close();break;case 38:case 40:case 37:case 39:self._traverse(e.which,this);break;case 13:$(this).find("input")[0].click();break}}).delegate('input[type="checkbox"], input[type="radio"]',"click.multiselect",function(e){var $this=$(this);var val=this.value;var optionText=$this.parent().find("span").text();var checked=this.checked;var tags=self.element.find("option");if(this.disabled||self._trigger("click",e,{value:val,text:optionText,checked:checked})===false){e.preventDefault();return}$this.focus();$this.prop("aria-selected",checked);tags.each(function(){if(this.value===val){this.selected=checked}else if(!self.options.multiple){this.selected=false}});if(!self.options.multiple){self.labels.removeClass("ui-state-active");$this.closest("label").toggleClass("ui-state-active",checked);self.close()}self.element.trigger("change");setTimeout($.proxy(self.update,self),10)});$doc.bind("mousedown."+self._namespaceID,function(event){var target=event.target;if(self._isOpen&&target!==self.button[0]&&target!==self.menu[0]&&!$.contains(self.menu[0],target)&&!$.contains(self.button[0],target)){self.close()}});$(this.element[0].form).bind("reset."+this._namespaceID,function(){setTimeout($.proxy(self.refresh,self),10)})},_getMinWidth:function(){var minVal=this.options.minWidth;var width=0;switch(typeof minVal){case"number":width=minVal;break;case"string":var lastChar=minVal[minVal.length-1];width=minVal.match(/\d+/);if(lastChar==="%"){width=this.element.parent().outerWidth()*(width/100)}else{width=parseInt(minVal,10)}break}return width},_setButtonWidth:function(){var width=this.element.outerWidth();var minVal=this._getMinWidth();if(width')).addClass("ui-multiselect ui-widget ui-state-default ui-corner-all").addClass(o.classes).attr({title:el.attr("title"),tabIndex:el.attr("tabIndex"),id:el.attr("id")?el.attr("id")+"_ms":null}).prop("aria-haspopup",true).insertAfter(el);this.buttonlabel=$("").html(o.noneSelectedText).appendTo(button);this.menu=$("
        ").addClass("ui-multiselect-menu ui-widget ui-widget-content ui-corner-all").addClass(o.classes).appendTo(this._getAppendEl());this.header=$("
        ").addClass("ui-widget-header ui-corner-all ui-multiselect-header ui-helper-clearfix").appendTo(this.menu);this.headerLinkContainer=$("
        '; + $('
        ').html( output_msg ).dialog({ + title: title_msg, + //resizable: true, + modal: true, + buttons: { + "Ok": function() { + $( this ).dialog( 'close' ); + } + } + }); + } +})(jQuery); diff --git a/admin/post-list-meta-box-design.php b/admin/post-list-meta-box-design.php new file mode 100644 index 0000000..e09b7b1 --- /dev/null +++ b/admin/post-list-meta-box-design.php @@ -0,0 +1,111 @@ + esc_html__( + 'Used to store any HTML & CSS code that exists before the post/content listings. Useful for div, ul, ol, tables, etc.. As well as storing CSS styling for IDs and Classes.', + 'advanced-post-list' + ), + 'list_content' => esc_html__( + 'This where you design how your posts are going to display in the post list. In here you can use HTML, CSS, PHP (requires the PHP shortcode), and the plugin\'s internal shortcodes. Info can be found at the bottom, or by clicking on the shortcode info found below "List content".', + 'advanced-post-list' + ), + 'after_list' => esc_html__( + 'Used for ending any elements that are still open, or to display a final message to the users/visitors.', + 'advanced-post-list' + ), + 'empty_message' => esc_html__( + 'This container holds the HTML & CSS content and if no posts are found to be listed in the preset. Then the preset post list will display this message. If no Empty Message is found, then the post list will use the Default Empty Message if enabled in the Plugin\'s Admin Settings. Otherwise, the plugin will display nothing like it was originally set as. Please Note: if you are using the Default Empty Message but you don\'t want to display anything in a certain preset post list. Then simple create an empty element to fall back on. For example, an empty "span" HTML element.', + 'advanced-post-list' + ), +); + +if ( 'apl_post_list' === $post->post_type ) { + $apl_post_list = new APL_Post_List( $post->post_name ); + $apl_design = new APL_Design( $apl_post_list->pl_apl_design ); +} else if ( defined( 'ICL_SITEPRESS_VERSION' ) && 'apl_design' === $post->post_type ) { + $apl_design = new APL_Design( $post->post_name ); +} + +?> + +
        +
        +
        +
        + + +
        +
        + +
        +
        +
        +
        + + +
        + + + + +
        +
        + +
        +
        +
        +
        + + +
        +
        + +
        +
        +
        +
        + + +
        +
        +
        + empty ) ? 'checked="checked"' : ''; ?> /> + +
        + +
        +
        + post_type ) : ?> +
        +
        +

        WPML Manage

        +
        +
        + id ) : ?> +
        + +
        + +

        + +
        +
        + +
        +
        diff --git a/admin/post-list-meta-box-filter.php b/admin/post-list-meta-box-filter.php new file mode 100644 index 0000000..b66ae63 --- /dev/null +++ b/admin/post-list-meta-box-filter.php @@ -0,0 +1,701 @@ + + esc_html__( 'Each (jQuiry UI) accordion contains a separate individual post type. The default post types built into WordPress are Post and Page. Any additional post types are dynamically added in the manner WordPress does. Please Note: Each post/page can have only one post type, which may explain why it has been divided by post types.', 'advanced-post-list' ), + 'taxonomy_tab' => + esc_html__( 'Each taxonomy is generally spit up in two sections, and divided into separate tabs. Hierarchies (categories) are located on the left, and non-hierarchies (tags) are located on the right.', 'advanced-post-list' ), + 'parent_page_tab' => + esc_html( 'Each hierarchical post type has a Parent selector for selecting which children pages to display. You can add multiple Post Parents of dynamically add children pages according to the Current Page.', 'advanced-post-list' ), + 'taxonomy_multiselect' => + esc_html( 'MULTISELECT Each taxonomy is generally spit up in two sections, and divided into separate tabs. Hierarchies (categories) are located on the left, and non-hierarchies (tags) are located on the right.', 'advanced-post-list' ) . + '

        ' . + esc_html( 'Req. Taxonomies: If more than one ‘Require Taxonomy’ is checked and terms (or include) are selected, or "any", then each taxonomy must be required within the post type.', 'advanced-post-list' ), + 'require_terms' => + esc_html__( 'If selected, and more than one term is checked, then each term must be required within the CPT/taxonomy in order to be displayed in the post list.', 'advanced-post-list' ), + 'dynamic_terms' => + esc_html__( 'If selected, the post list preset will include any terms the current page/post has within the CTP/taxonomy.', 'advanced-post-list' ), + 'any_terms' => + esc_html__( 'When checked, any terms will be included within that CPT/taxonomy.', 'advanced-post-list' ), + 'list_amount' => + esc_html__( 'The numeric value of how many posts you want the post list to display. Negative one (-1) will display all the posts that are available after filtering.', 'advanced-post-list' ), + 'order_by' => + esc_html__( 'Choose which page properties to sort from. All of which are built in params used in WP_Query.', 'advanced-post-list' ), + 'authors' => + esc_html( 'Show or remove posts that were created by a certain author, or authors. You can only choose between adding or removing, not both.', 'advanced-post-list' ) . + '

        ' . + esc_html( 'Operator - Determines whether you want to include or exclude authors.', 'advanced-post-list' ) . + '

        ' . + esc_html( 'Author Names/IDs - Displays a list of authors the site currently has and is divided/grouped into separate role groups.', 'advanced-post-list' ), + 'post_status' => + esc_html( 'Holds the settings to show which posts to display based on the user visibility and/or the page states. To which is only visible to the users with the necessary capabilities to view them.', 'advanced-post-list' ) . + '

        ' . + esc_html( 'Visibility - Display posts as either Public, Private, or Both', 'advanced-post-list' ) . + '

        ' . + esc_html( 'Status States: Choose from Published, Future, Pending Review, Draft, Auto-save, Inherit, and/or Trash.', 'advanced-post-list' ), + 'user_perms' => + esc_html__( 'Uses the user permission via. user capabilities to determine what posts to display in the post list to the visitor/user.', 'advanced-post-list' ), + 'offset' => + esc_html( 'Number of posts to skip/displace.', 'advanced-post-list' ) . + '
        ' . + esc_html( 'NOTE: Offset is ignored when List Amount is set to -1 (show all posts).', 'advanced-post-list' ), + 'exclude_posts_by_id' => + esc_html__( 'Add post/page IDs, seperated by a comma (,), will prevent those posts from being added to the post list.', 'advanced-post-list' ), + 'enable_sticky_posts' => + esc_html__( 'Meant for the built-in post type (Posts) function. When checked, this will prevent sticky posts from always displaying at the top of the post list.', 'advanced-post-list' ), + 'exclude_current_post' => + esc_html__( 'When checked, the current post being viewed will be excluded from the post list.', 'advanced-post-list' ), + 'exclude_duplicate_posts' => + esc_html__( 'In the "order that it is received", each preset post list being viewed will add the post IDs to a global exclude list built into APL. When checked, the preset post list will add the post IDs (listed at the time) to the exclude filter settings in WP_Query. This will remove any posts that have already been displayed to the user by the APL plugin.', 'advanced-post-list' ), +); +?> + $taxonomy, + 'parent' => $term_parent, + 'hide_empty' => false, + ); + $terms = get_terms( $args ); + + $first_term = true; + + ?> + +
          + + tax_query[ $post_type ] ) ) { + foreach ( $apl_post_list->tax_query[ $post_type ] as $k1_pl_index => $v1_pl_tax_query ) { + if ( 'relation' !== $k1_pl_index ) { + if ( $taxonomy === $v1_pl_tax_query['taxonomy'] && empty( $v1_pl_tax_query['terms'] ) ) { + $term_checked = 'checked="checked"'; + } + } + } + } + + ?> +
        • + +
        • + + + $v_term_obj ) : ?> + term_id; + + $term_checked = ''; + if ( isset( $apl_post_list->tax_query[ $post_type ] ) ) { + foreach ( $apl_post_list->tax_query[ $post_type ] as $k2_pl_index => $v2_pl_tax_query ) { + if ( 'relation' !== $k2_pl_index ) { + if ( $taxonomy === $v2_pl_tax_query['taxonomy'] && in_array( $v_term_obj->term_id, $v2_pl_tax_query['terms'], true ) ) { + $term_checked = 'checked="checked"'; + } + } + } + } + ?> +
        • + +
        • + term_id, ( $indent + 1 ) ); ?> + + +
        + $post_type, + 'post_parent' => $page_parent, + 'posts_per_page' => -1, + 'order' => 'DESC', + 'orderby' => 'name', + ); + $query_pages = new WP_Query( $args ); + + $indent_str = ''; + for ( $i = 0; $i < $indent; $i++ ) { + $indent_str .= '—'; + } + + $page_dynamic_checked = ''; + if ( isset( $apl_post_list->post_parent_dynamic[ $post_type ] ) ) { + if ( true === $apl_post_list->post_parent_dynamic[ $post_type ] ) { + $page_dynamic_checked = 'checked="checked"'; + } + } + + $apl_help_text_parent = esc_html__( + 'Adds the Current Page being displayed as a Parent Page, which will then add those child pages.', + 'advanced-post-list' + ); + ?> + + > + + +
        +
        + + + + + + + + + + + have_posts() ) : ?> + the_post(); + $ele_tag = $post_type . '-' . $query_pages->post->ID; + + $page_checked = ''; + if ( isset( $apl_post_list->post_parent__in[ $post_type ] ) ) { + if ( in_array( $query_pages->post->ID, $apl_post_list->post_parent__in[ $post_type ], true ) ) { + $page_checked = 'checked="checked"'; + } + } + ?> + + + + + + post->ID, ( $indent + 1 ) ); + ?> + + + + + + + + + + +
        + /> + + post->ID ); ?> + + +
        + + +post_name ); + +$apl_post_type_objs = get_post_types( '', 'objects' ); + +$apl_taxonomy_objs = get_taxonomies( '', 'objects' ); + +$apl_term_objs_arr = array(); +foreach ( $apl_tax_terms as $key => $value ) { + $args = array( + 'taxonomy' => $key, + 'hide_empty' => false, + ); + $apl_term_objs_arr[ $key ] = get_terms( $args ); +} + +?> +
        +
        +

        + + +

        +
        + + $v_arr ) : ?> + post_type, $k_pt_slug ); + if ( $first_pt && empty( $apl_post_list->post_type ) ) { + $checked = 'checked="checked"'; + } + $first_pt = false; + ?> + > + +
        + +
        +
        +
        + + + $v_pt_arr ) : ?> + post_type, $k_pt_slug ); + if ( $first_pt && empty( $apl_post_list->post_type ) ) { + $display = 'display: block;'; + } + $first_pt = false; + ?> +
        +

        +
        +
          + +
        • + +
          +
          +
        • + + + hierarchical ) : ?> +
        • + +
          +
          +
        • + + +
        + + +
        +
        + + +
        +
        +
        +
          + + $tax_slug ) : ?> + tax_query[ $k_pt_slug ] ) ) { + foreach ( $apl_post_list->tax_query[ $k_pt_slug ] as $k3_pl_tax_query => $v3_pl_tax_query ) { + if ( 'relation' !== $k3_pl_tax_query ) { + if ( $tax_slug === $v3_pl_tax_query['taxonomy'] ) { + $tax_display = 'display: block;'; + } + } + } + } + if ( $first_tax && ! isset( $apl_post_list->tax_query[ $k_pt_slug ] ) ) { + $tax_display = 'display: block;'; + } + $first_tax = false; + ?> +
        • labels->singular_name ); ?>
        • + +
        + + $tax_slug ) : ?> + tax_query[ $k_pt_slug ] ) ) { + foreach ( $apl_post_list->tax_query[ $k_pt_slug ] as $k3_pl_tax_query => $v3_pl_tax_query ) { + if ( 'relation' !== $k3_pl_tax_query ) { + if ( $tax_slug === $v3_pl_tax_query['taxonomy'] ) { + $tax_display = 'display: block;'; + // Require Terms Checkbox. + if ( 'AND' === $v3_pl_tax_query['operator'] ) { + $tax_chk_required = 'checked="checked"'; + } + if ( true === $v3_pl_tax_query['apl_terms_dynamic'] ) { + $tax_chk_dynamic = 'checked="checked"'; + } + } + } + } + + if ( $first_tax && ! isset( $apl_post_list->tax_query[ $k_pt_slug ] ) ) { + $tax_display = 'display: block;'; + $first_tax = false; + } + } + ?> +
        + + +
          +
        • + + +
        • +
        • + + +
        • +
        + +
        + +
        + +
        +
        +
        + + + + hierarchical ) : ?> +
        + +
        + + +
        +
        + +
        +
        +
        + +
        + +
        +
        + + + +
        +
        +
        + +
        +
        +
        +
        +
        +
        +
        +
        + +
        +
        + + +
        +
        +
        + + +
        +
        +
        +
        +
        +
        + +
        +
        + +
        +
        + + +
        +
        + + +
        +
        + +
        +
        + + +
        +
        +
        + + + +
        +
        +
        + +
        +
        + + +
        +
        + + +
        +
        +
        +
        + + +
        +
        + +
        +
        +
        + +
        + +
        + + +
        +
        + +
        + +
        + + + ignore_sticky_posts ) ? 'checked="checked"' : ''; ?> /> +
        + +
        + + + pl_exclude_current ) ? 'checked="checked"' : ''; ?> /> +
        + +
        + + + pl_exclude_dupes ) ? 'checked="checked"' : ''; ?> + pl_exclude_dupes ) ? 'checked="checked"' : ''; ?> /> +
        +
        +
        diff --git a/admin/settings-meta-box-general.php b/admin/settings-meta-box-general.php new file mode 100644 index 0000000..4161e3d --- /dev/null +++ b/admin/settings-meta-box-general.php @@ -0,0 +1,87 @@ + $value ) { + $tmp_post_types[ $key ] = $value->labels->singular_name; +} + +$apl_help_text = array( + 'ignore_post_types' => + esc_html__( 'Used for ignoring post types when creating/editing a post list.', 'advanced-post-list' ), + 'delete_on_deactivate' => + esc_html__( 'If "No" is selected, then the plugin\'s database data will not be removed when the plugin is deactivated. When re-activated, the plugin data will restored as it was left. Please Note: If the plugin is removed/uninstalled, then the plugin\'s data will be removed regardless.', 'advanced-post-list' ), + 'default_empty_enable' => + '' . esc_html__( 'Enable Default Empty Message: ', 'advanced-post-list' ) . '' . + esc_html__( 'Used as a default option to use if no posts are found and the Empty Message is empty within the preset post list.', 'advanced-post-list' ) . '
        ' . + '' . esc_html__( 'Enable Global Exit (boolean): ', 'advanced-post-list' ) . '' . + esc_html__( 'If enabled (yes), the all presets will fallback on the global/default Empty Message.', 'advanced-post-list' ) . '
        ' . + '' . esc_html__( 'Empty Message: ', 'advanced-post-list' ) . '' . + esc_html__( 'Contains the message that will be displayed if no posts are found. HTML and CSS can be used.', 'advanced-post-list' ), +); +?> +
        + +
        +
        + + +
        +
        + $v1_name ) : ?> + /> + +
        + +
        +
        +
        +
        + + +
        +
        + /> + +
        +
        + /> + +
        +
        +
        +
        + + +
        +
        + /> + +
        +
        + /> + +
        +
        +
        + +
        + +
        diff --git a/admin/settings-meta-box-import-export.php b/admin/settings-meta-box-import-export.php new file mode 100644 index 0000000..69a4b79 --- /dev/null +++ b/admin/settings-meta-box-import-export.php @@ -0,0 +1,76 @@ + + esc_html__( 'Exports the whole APL preset database/table. Illegal (< > : " / \ | , ? *) characters cannot be used as the exported filename.', 'advanced-post-list' ) . '
        ', + 'import_file' => + esc_html__( 'Imports data into the database. If there are any pre-existing data, you will be prompted list of overwrite items.', 'advanced-post-list' ) . '
        ', + 'restore_defaults' => + esc_html__( 'Designed to restore only the default preset table the plugin initially came with.', 'advanced-post-list' ) . '
        ', +); +?> + +
        +

        +
        +
        + + +
        +
        + + +
        +
        + +
        + +

        +
        +
        + +
        + + +
        +
        + +
        + +
        +
        +
        +
        +
        + +

        +
        +
        + + +
        +
        +

        + +

        +

        + +

        +
        + +
        +
        + +
        +
        + + diff --git a/admin/settings-meta-box-info.php b/admin/settings-meta-box-info.php new file mode 100644 index 0000000..f0f7619 --- /dev/null +++ b/admin/settings-meta-box-info.php @@ -0,0 +1,33 @@ + +
        +

        + Designed from inspiration, and for developers/designers alike, Advanced Post List + has seen a number significant steps forward. Although the number may be small, + with the upgrade of 0.4, it packs a significant list of upgrades and changes. +

        +

        + If you discover a bug, it helps to report the issue to either. +

        + Any feedback is greatly appreciated. +

        +

        Additional Links

        + +
        Version:
        +
        diff --git a/admin/settings-page.php b/admin/settings-page.php new file mode 100644 index 0000000..fb54e9e --- /dev/null +++ b/admin/settings-page.php @@ -0,0 +1,47 @@ + + +
        +

        + + +
        + +
        +
        +
        + +
        +
        + +
        +
        + +
        +
        + +
        +
        + + +
        diff --git a/advanced-post-list.php b/advanced-post-list.php index d220602..20d9a8e 100644 --- a/advanced-post-list.php +++ b/advanced-post-list.php @@ -1,57 +1,51 @@ Please update!', 'advanced-post-list' ); - wp_die( esc_html( $error_msg ), 'Advanced Post List: Error' ); + $error_msg .= esc_html__( 'This plugin requires Wordpress 2.0.2 or higher to operate. ', 'advanced-post-list' ); + $error_msg .= esc_html__( 'Please update!', 'advanced-post-list' ); + wp_die( esc_html( $error_msg ), esc_html__( 'Advanced Post List: Error', 'advanced-post-list' ) ); } } else { $error_msg = __( 'You are attempting to access this plugin directly.', 'advanced-post-list' ); - wp_die( esc_html( $error_msg ), 'Advanced Post List: Error' ); + wp_die( esc_html( $error_msg ), esc_html__( 'Advanced Post List: Error', 'advanced-post-list' ) ); } -/******************************************************************************/ -/**** Core Singleton Class ****************************************************/ -/******************************************************************************/ - +/* **** Core Singleton Class **** */ require_once( plugin_dir_path( __FILE__ ) . 'includes/class/class-apl-core.php' ); $advanced_post_list = new APL_Core( __FILE__ ); diff --git a/includes/class/class-apl-core.php b/includes/class/class-apl-core.php index e7915de..ea7295c 100644 --- a/includes/class/class-apl-core.php +++ b/includes/class/class-apl-core.php @@ -4,10 +4,9 @@ * * Core object to Advanced Post List * - * @link https://github.com/EkoJr/advanced-post-list/ + * @link https://github.com/Advanced-Post-List/advanced-post-list/ * - * @package WordPress - * @subpackage advanced-post-list.php + * @package advanced-post-list * @since 0.1.0 */ @@ -19,41 +18,23 @@ * @since 0.1.0 * @since 0.2.0 * @since 0.3.0 + * @since 0.4.0 - Removed Admin functions and added into APL_Admin class. */ class APL_Core { - // Varibles - // ???MIGHT WANT TO ADD VERSION TO OPTIONS DB. - /** - * Stores error message when error occurs. - * - * @since 0.1.0 - * @access private - * @var string - */ - private $_error; - - /** - * Summary. - * - * @since 0.1.0 - * @since 0.4.0 Change name $_errorLog to $_error_log - * @access private - * @var string - */ - private $_error_log; /** - * Summary. + * APL Options Name * * @since 0.1.0 * @since 0.4.0 Changed name $_APL_OPTION_NAME to $_option_name + * @deprecated 0.4.0 Recommend manual param. * @access public * @var string */ - private $_option_name = 'APL_Options'; + private $_option_name = 'apl_options'; /** - * Summary. + * Remove/Prevent Duplicate Posts * * @since 0.3.0 * @access public @@ -61,47 +42,23 @@ class APL_Core { */ private $_remove_duplicates = array(); - // PHP Doc WP Template. - /** - * Summary. - * - * Description. - * - * @since x.x.x - * @access (for functions: only use if private) - * - * @see Function/method/class relied on - * @link URL - * @global type $varname Description. - * @global type $varname Description. - * - * @param type $var Description. - * @param type $var Optional. Description. Default. - * @return type Description. - */ - /** * Core Constructor * * Constructor for APL_Core functionality. * * STEP 1: Set plugin file data/properties. - * STEP 2: Check database version with the current file version. - * STEP 3: Register activation, deactivation, and un-install hooks with WordPress. - * STEP 4: Add Shortcode to WordPress action hooks. - * STEP 5: If the current user has admin rights, do **Step 6**. - * STEP 6: Add APL's menu to WordPress 'admin_menu' action hook and - * APL's initial admin action hooks to WordPress 'admin_menu' - * action hook. + * STEP 2: Add Hooks. + * STEP 3: Add Admin Hooks. * * @since 0.1.0 * @since 0.2.0 - Refined how version checking was performed. - * @since 0.4.0 - Added hook for loading the textdomain to enable + * @since 0.4.0 - Added hook for loading the textdomain to enable * internalization support. + * Changed check version to hook method. * @access public * * @param string $file Main plugin file. - * @return void */ public function __construct( $file ) { // STEP 1. @@ -109,52 +66,40 @@ public function __construct( $file ) { $this->_requires(); // STEP 2. - /* **** DATABASE **** */ - $options = $this->apl_options_load(); - if ( isset( $options['version'] ) ) { - /***** UPGRADES *****/ - - /* - * Put upgrade database functions in here. Not before. - * Ex. APL_upgrade_to_XXX(). - */ - if ( version_compare( $options['version'], APL_VERSION, '<' ) ) { - $options = $this->_update( $options ); - } - } - /* **** ACTION & FILTERS HOOKS **** */ + add_action( 'plugins_loaded', array( $this, 'action_check_version' ) ); + add_action( 'init', array( $this, 'action_register_post_type_post_list' ) ); + add_action( 'init', array( $this, 'action_register_post_type_design' ) ); + add_action( 'plugins_loaded', array( $this, 'action_load_plugin_textdomain' ) ); + + // Public Hooks. + add_shortcode( 'post_list', array( $this, 'shortcode_post_list' ) ); + add_action( 'widgets_init', array( $this, 'action_widget_init' ) ); - // STEP - Add hook to load plugin textdomain when plugins are loaded. - add_action( 'plugins_loaded', array( $this, 'hook_action_load_plugin_textdomain' ) ); // STEP 3. - add_action( 'widgets_init', array( $this, 'hook_action_widget_init' ) ); - // STEP 4. - add_shortcode( 'post_list', array( $this, 'hook_shortcode_post_list' ) ); - // STEP 5. if ( is_admin() ) { - // STEP 6. - add_action( 'admin_menu', array( $this, 'hook_action_admin_menu' ) ); - // STEP 7. - add_action( 'admin_init', array( $this, 'hook_action_admin_init' ) ); + // Admin Class + add_action( 'init', array( 'APL_Admin', 'get_instance' ) ); /* **** ACTIVATE/DE-ACTIVATE/UNINSTALL HOOKS **** */ - $file_dir = APL_DIR . 'advanced-post-list/advanced-post-list.php'; - register_activation_hook( $file_dir, array( 'APL_Core', 'hook_activation' ) ); - register_deactivation_hook( $file_dir, array( 'APL_Core', 'hook_deactivation' ) ); - register_uninstall_hook( $file_dir, array( 'APL_Core', 'hook_uninstall' ) ); + $file_dir = APL_DIR . 'advanced-post-list.php'; + register_activation_hook( $file_dir, array( 'APL_Core', 'activation' ) ); + register_deactivation_hook( $file_dir, array( 'APL_Core', 'deactivation' ) ); + register_uninstall_hook( $file_dir, array( 'APL_Core', 'uninstall' ) ); } } /** - * Define APL Constants. + * Define APL Constants * * Defines all the constants for APL. * + * @ignore * @since 0.3.2 * @access private * - * @see Function/method/class relied on + * @see get_file_data() + * @link https://hitchhackerguide.com/2011/02/12/get_plugin_data/ * * @param string $plugin_file Main plugin file. */ @@ -176,7 +121,7 @@ private function _define_constants( $plugin_file ) { * @since 0.1.0 * @since 0.3.2 - Moved from advanced-post-list.php to class-apl-core * APL_Core::_define_constants(). - * @var string APL_NAME 'Advanced Post List'. + * @var string $APL_NAME Contains 'Advanced Post List'. */ define( 'APL_NAME', $plugin_data['Name'] ); @@ -184,7 +129,7 @@ private function _define_constants( $plugin_file ) { * APL Slug. * * @since 0.3.2 - * @var string APL_SLUG 'advanced-post-list'. + * @var string $APL_SLUG Contains 'advanced-post-list'. */ define( 'APL_SLUG', $plugin_data['Slug'] ); @@ -194,7 +139,7 @@ private function _define_constants( $plugin_file ) { * @since 0.1.0 * @since 0.3.2 - Moved from advanced-post-list.php to class-apl-core * APL_Core::_define_constants(). - * @var string APL_VERSION '1.2.3'. + * @var string $APL_VERSION Ex. '1.2.3'. */ define( 'APL_VERSION', $plugin_data['Version'] ); @@ -204,7 +149,7 @@ private function _define_constants( $plugin_file ) { * @since 0.1.0 * @since 0.3.2 - Moved from advanced-post-list.php to class-apl-core * APL_Core::_define_constants(). - * @var string APL_URL 'http://localhost/wordpress/wp-content/plugins/advanced-post-list/'. + * @var string $APL_URL Contains 'http://localhost/wordpress/wp-content/plugins/advanced-post-list/'. */ define( 'APL_URL', plugin_dir_url( $plugin_file ) ); @@ -214,16 +159,17 @@ private function _define_constants( $plugin_file ) { * @since 0.1.0 * @since 0.3.2 - Moved from advanced-post-list.php to class-apl-core * APL_Core::_define_constants(). - * @var string APL_DIR 'C:\xampp\htdocs\wordpress\wp-content\plugins\advanced-post-list/'. + * @var string $APL_DIR Contains 'C:\xampp\htdocs\wordpress\wp-content\plugins\advanced-post-list/'. */ define( 'APL_DIR', plugin_dir_path( $plugin_file ) ); } /** - * Add Required Files. + * Add Required Files * * Adds the required files to include. * + * @ignore * @since 0.3.0 * @access private * @@ -231,269 +177,250 @@ private function _define_constants( $plugin_file ) { * @global string APL_DIR APL file path. */ private function _requires() { - require_once( APL_DIR . 'includes/class/class-apl-preset-db.php' ); - require_once( APL_DIR . 'includes/class/class-apl-preset.php' ); + // PUBLIC. + // Class Objects. + require_once( APL_DIR . 'includes/class/class-apl-post-list.php' ); + require_once( APL_DIR . 'includes/class/class-apl-design.php' ); require_once( APL_DIR . 'includes/class/class-apl-widget.php' ); require_once( APL_DIR . 'includes/class/class-apl-query.php' ); require_once( APL_DIR . 'includes/class/class-apl-updater.php' ); // OLD - Remove between 0.4 - 0.6. + require_once( APL_DIR . 'includes/class/dep-class-apl-preset-db.php' ); + require_once( APL_DIR . 'includes/class/dep-class-apl-preset.php' ); require_once( APL_DIR . 'includes/class/old-APLPresetDbObj.php' ); require_once( APL_DIR . 'includes/class/old-APLPresetObj.php' ); - // TODO Move to Admin only function/method. - require_once( APL_DIR . 'admin/import.php' ); - require_once( APL_DIR . 'admin/export.php' ); + // Functions. + require_once( APL_DIR . 'includes/functions.php' ); + + // ADMIN + require_once( APL_DIR . 'admin/class-apl-admin.php' ); } /** - * APL Updater. - * - * Updater method for handling the Upgrader Class. + * Register the Design Post Type * - * @since 0.3.0 - * @access private + * Hook for loading the textdomain location. * - * @see Function/method/class relied on - * @link URL + * @since 0.4.0 * - * @param object $options APL Options. - * @return object APL Options. - */ - private function _update( $options ) { - $preset_db = new APL_Preset_Db( 'default' ); - $updater = new APL_Updater( $options['version'], $preset_db, $options ); - // IN THIS CASE, BOTH MUST HAVE VALUES FILLED. - if ( null === $updater->options || null === $updater->preset_db ) { - return $options; - } else { - $preset_db = $updater->preset_db; - $preset_db->options_save_db(); - $options = $updater->options; - $this->apl_options_save( $options ); + * @link https://codex.wordpress.org/Function_Reference/register_post_type WP Codex. + */ + public function action_register_post_type_post_list() { + + $args = array( + 'labels' => array( + 'name' => __( 'APL Post Lists', 'advanced-post-list' ), + 'singular_name' => __( 'Post List', 'advanced-post-list' ), + 'add_new' => _x( 'Add New', 'List', 'advanced-post-list' ), + 'add_new_item' => __( 'Add New Post List', 'advanced-post-list' ), + 'edit_item' => __( 'Edit Post List', 'advanced-post-list' ), + 'new_item' => __( 'New Post List', 'advanced-post-list' ), + 'view_item' => __( 'View Post List', 'advanced-post-list' ), + 'view_items' => __( 'View Post Lists', 'advanced-post-list' ), + 'search_items' => __( 'Search Post Lists', 'advanced-post-list' ), + 'not_found' => __( 'No Post Lists found', 'advanced-post-list' ), + 'not_found_in_trash' => __( 'No Post Lists found in Trash', 'advanced-post-list' ), + 'parent_item_colon' => __( ':', 'advanced-post-list' ), + 'all_items' => __( 'All Post Lists', 'advanced-post-list' ), + 'archives' => __( 'Post List Archives', 'advanced-post-list' ), + 'attributes' => __( 'Post List Attributes', 'advanced-post-list' ), + 'insert_into_item' => __( 'Insert into Post List', 'advanced-post-list' ), + 'uploaded_to_this_item' => __( 'Upload to this Post List', 'advanced-post-list' ), + 'menu_name' => __( 'APL Post List', 'advanced-post-list' ), + ), + 'description' => __( 'APL Preset Post Lists.', 'advanced-post-list' ), + 'public' => true, + 'exclude_from_search' => true, + 'publicly_queryable' => false, + 'show_ui' => true, // Shows up in admin menu bar. + 'show_in_menu' => 'advanced_post_list', + 'show_in_nav_menus' => false, + 'show_in_admin_bar' => true, + 'menu_position' => 58, + 'menu_icon' => 'dashicons-welcome-widgets-menus', + 'hierarchical' => true, + 'supports' => array( + 'title', + //'author', + //'thumbnail', + //'revisions', + ), + 'has_archive' => false, + // Disables the URL query /?{query_var}={single_post_slug}. + 'query_var' => false, + //'can_export' => true, // Default true. + 'delete_with_user' => false, + ); - return $options; - } + $args = apply_filters( 'apl_register_post_type_post_list', $args ); + register_post_type( 'apl_post_list', $args ); } - + /** - * Load APL's Textdomain. + * Register the Design Post Type * * Hook for loading the textdomain location. * * @since 0.4.0 * - * @link https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/ - * - * @return void - */ - public function hook_action_load_plugin_textdomain() { - load_plugin_textdomain( APL_SLUG, false, APL_DIR . '/languages/' ); + * @link https://codex.wordpress.org/Function_Reference/register_post_type WP Codex. + */ + public function action_register_post_type_design() { + $args = array( + 'labels' => array( + 'name' => __( 'APL Designs', 'advanced-post-list' ), + 'singular_name' => __( 'Design', 'advanced-post-list' ), + 'add_new' => _x( 'Add New', 'design', 'advanced-post-list' ), + 'add_new_item' => __( 'Add New Design', 'advanced-post-list' ), + 'edit_item' => __( 'Edit Design', 'advanced-post-list' ), + 'new_item' => __( 'New Design', 'advanced-post-list' ), + 'view_item' => __( 'View Design', 'advanced-post-list' ), + 'view_items' => __( 'View Designs', 'advanced-post-list' ), + 'search_items' => __( 'Search Designs', 'advanced-post-list' ), + 'not_found' => __( 'No Design found', 'advanced-post-list' ), + 'not_found_in_trash' => __( 'No Design found in Trash', 'advanced-post-list' ), + 'parent_item_colon' => __( ':', 'advanced-post-list' ), + 'all_items' => __( 'All Designs', 'advanced-post-list' ), + 'archives' => __( 'Design Archives', 'advanced-post-list' ), + 'attributes' => __( 'Design Attributes', 'advanced-post-list' ), + 'insert_into_item' => __( 'Insert into Design', 'advanced-post-list' ), + 'uploaded_to_this_item' => __( 'Upload to this Design', 'advanced-post-list' ), + 'menu_name' => __( 'APL Design', 'advanced-post-list' ), + ), + 'description' => __( 'APL Designs for Preset Post Lists.', 'advanced-post-list' ), + 'public' => true, + 'exclude_from_search' => true, + 'publicly_queryable' => false, + // Shows up in admin area. + 'show_ui' => false, + 'show_in_menu' => false, + 'show_in_nav_menus' => false, + 'show_in_admin_bar' => false, + 'menu_icon' => 'dashicons-admin-generic', + 'hierarchical' => true, + 'supports' => array( + 'title', + //'thumbnail', + //'excerpt', + //'revisions', + ), + 'has_archive' => false, + // Disables the URL query /?{query_var}={single_post_slug}. + 'query_var' => false, + //'can_export' => true, // Default true. + 'delete_with_user' => false, + ); + + if ( defined( 'ICL_SITEPRESS_VERSION' ) ) { + $args['show_ui'] = true; + } + + $args = apply_filters( 'apl_register_post_type_design', $args ); + register_post_type( 'apl_design', $args ); } /** - * Admin init. - * - * Adds plugin action hooks to admin_init for loading up when the user - * has admin rights. + * Hook for APL check version * - * STEP 1 - Add action hooks for AJAX. - * STEP 2 - De-register scripts and style for a clean register. - * STEP 3 - Load APLOptions to load selected JQuery UI theme. - * STEP 4 - Register scripts to be enqueued. - * STEP 5 - Register styles. + * Update method for handling the Upgrader Class. * - * @since 0.1.0 - * @since 0.2.0 - Added export, import, and save settings ajax functions. - * @since 0.3.0 - Added wp_enqueue_script & wp_enqueue_style to place them - * in separate files properly. Also added a theme setting - * to be loaded. + * @since 0.3.0 + * @since 0.4.0 - Changed to action hook. * @access public * - * @see apl_import in '/advanced-post-list/admin/import.php' - * @see apl_export in '/advanced-post-list/admin/export.php' - * @link URL + * @see 'plugins_loaded' action hook. + * @link https://codex.wordpress.org/Plugin_API/Action_Reference/plugins_loaded + * @link https://developer.wordpress.org/reference/hooks/plugins_loaded/ */ - public function hook_action_admin_init() { - /* - * ************** AJAX ACTION HOOKS *************************** - */ - - // STEP 1. - add_action( - 'wp_ajax_APL_handler_save_preset', - array( $this, 'hook_action_ajax_save_preset' ) - ); - add_action( - 'wp_ajax_APL_handler_delete_preset', - array( $this, 'hook_action_ajax_delete_preset' ) - ); - add_action( - 'wp_ajax_APL_handler_restore_preset', - array( $this, 'hook_action_ajax_restore_preset' ) - ); - - add_action( - 'wp_ajax_APL_handler_export', - array( $this, 'hook_action_ajax_export' ) - ); - add_action( - 'wp_ajax_APL_handler_import', - array( $this, 'hook_action_ajax_import' ) - ); - add_action( - 'wp_ajax_APL_import', - 'apl_import' - ); - add_action( - 'wp_ajax_APL_export', - 'apl_export' - ); - - add_action( - 'wp_ajax_APL_handler_save_settings', - array( $this, 'hook_action_ajax_save_settings' ) - ); - - /* - * ************** REMOVE SCRIPTS & STYLES ********************* - */ - - // Step 2. - wp_deregister_script( 'apl-admin-js' ); - wp_deregister_script( 'apl-admin-ui-js' ); - wp_deregister_script( 'apl-jquery-ui-multiselect-js' ); + public function action_check_version() { + $options = apl_options_load(); + if ( isset( $options['version'] ) ) { + if ( version_compare( $options['version'], APL_VERSION, '<' ) ) { + $preset_db = new APL_Preset_Db( 'default' ); - wp_deregister_style( 'apl-admin-css' ); - wp_deregister_style( 'apl-admin-ui-css' ); - wp_deregister_style( 'apl-jquery-ui-multiselect' ); - wp_deregister_style( 'apl-jquery-ui-multiselect-css' ); - wp_deregister_style( 'apl-jquery-ui-multiselect-filter-css' ); + $update_items = array( + 'options' => $options, + 'preset_db' => $preset_db, + ); - // Step 3. - $otions = $this->apl_options_load(); - if ( ! isset( $otions['jquery_ui_theme'] ) ) { - $otions['jquery_ui_theme'] = 'overcast'; - $this->apl_options_save( $otions ); + $updater = new APL_Updater( $options['version'], $update_items, 'APL' ); + // IN THIS CASE, BOTH MUST HAVE VALUES FILLED. + if ( $updater->update_occurred ) { + $this->update_post_list_database( $updater->apl_post_list_arr ); + $this->update_design_database( $updater->apl_design_arr ); + + $options = $updater->options; + apl_options_save( $options ); + } + } } + } - /* - * ************** REGISTER SCRIPTS **************************** - */ - - // Step 4. - $script_deps = array( 'jquery', 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-dialog' ); - wp_register_script( - 'apl-admin-js', - plugins_url() . '/advanced-post-list/admin/js/admin.js', - $script_deps, - APL_VERSION, - false - ); - - $script_deps = array( 'jquery', 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-accordion', 'jquery-ui-button','jquery-ui-dialog', 'jquery-ui-tabs' ); - wp_register_script( - 'apl-admin-ui-js', - plugins_url() . '/advanced-post-list/admin/js/admin-ui.js', - $script_deps, - APL_VERSION, - false - ); - - $script_deps = array( 'jquery', 'jquery-ui-core', 'jquery-ui-widget' ); - wp_register_script( - 'apl-jquery-ui-multiselect-js', - plugins_url() . '/advanced-post-list/admin/js/jquery.multiselect.min.js', - $script_deps, - APL_VERSION, - false - ); - - $script_deps = array( 'jquery', 'jquery-ui-core', 'jquery-ui-widget' ); - wp_register_script( - 'apl-jquery-ui-multiselect-filter-js', - plugins_url() . '/advanced-post-list/admin/js/jquery.multiselect.filter.min.js', - $script_deps, - APL_VERSION, - false - ); - - /* - * ************** REGISTER STYLES ***************************** - */ - - // Step 5. - wp_enqueue_style( - 'apl-admin-css', - plugins_url() . '/advanced-post-list/admin/css/admin.css', - false, - APL_VERSION, - false - ); - - wp_enqueue_style( - 'apl-admin-ui-css', - 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/' . $otions['jquery_ui_theme'] . '/jquery-ui.css', - false, - APL_VERSION, - false - ); + /** + * Update Post List Database + * + * Updates or adds to database via APL_Post_List object. + * + * @since 0.4.0 + * @access private + * + * @param array $apl_post_list_arr + */ + public function update_post_list_database( $apl_post_list_arr ) { + foreach ( $apl_post_list_arr as $k1_ => $apl_post_list ) { + $apl_post_list->save_post_list(); + } + } - wp_enqueue_style( - 'apl-jquery-ui-multiselect-css', - plugins_url() . '/advanced-post-list/admin/css/jquery.multiselect.css', - false, - APL_VERSION, - false - ); - wp_enqueue_style( - 'apl-jquery-ui-multiselect-filter-css', - plugins_url() . '/advanced-post-list/admin/css/jquery.multiselect.filter.css', - false, - APL_VERSION, - false - ); + /** + * Update Design Database + * + * Updates or adds to database via APL_Design object. + * + * @ignore + * @since 0.4.0 + * @access private + * + * @param array $apl_post_list_arr + */ + private function update_design_database( $apl_design_arr ) { + foreach ( $apl_design_arr as $apl_design ) { + $apl_design->save_design(); + } + } + /** + * Load APL's Textdomain + * + * Hook for loading the textdomain location. + * + * @since 0.4.0 + * + * @link https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/ + */ + public function action_load_plugin_textdomain() { + $lang_dir = APL_DIR . '/languages/'; + load_plugin_textdomain( APL_SLUG, false, $lang_dir ); } /** - * Summary. + * WP Plugin Activation * * Handles the activation method when the plugin is first activated. * - * STEP 1 - Load APLOptions. - * STEP 2 - If no options was loaded then install options to be loaded. - * * @since 0.1.0 * @access public */ - public function hook_activation() { + public static function activation() { // Step 1. - $options = get_option( 'APL_Options' ); - // Step 2. - if ( false === $options ) { - $options = array(); - } - if ( ! isset( $options['version'] ) ) { - $options['version'] = APL_VERSION; - } - if ( ! isset( $options['preset_db_names'] ) ) { - $options['preset_db_names'] = array( - 0 => 'default', - ); - } - if ( ! isset( $options['delete_core_db'] ) ) { - $options['delete_core_db'] = false; - } - if ( ! isset( $options['jquery_ui_theme'] ) ) { - $options['jquery_ui_theme'] = 'overcast'; - } - if ( ! isset( $options['error'] ) ) { - $options['error'] = ''; - } - update_option( 'APL_Options', $options ); + $options = apl_options_load(); + + // Any Need? apl_options_load() already sets defaults if no data is found. + apl_options_save( $options ); } /** - * Summary. + * WP Plugin De-activation * * Handles the deactivation method when plugin is deactivated * @@ -504,103 +431,139 @@ public function hook_activation() { * @since 0.1.0 * @since 0.2.0 - Added delete_option('APL_preset_db-default') for deleting * preset database data. + * @since 0.4.0 - Change database to Post Data to uninstall. + * + * @link https://developer.wordpress.org/reference/functions/unregister_post_type/ * @access public */ - public function hook_deactivation() { + public static function deactivation() { // STEP 1. - $options = get_option( 'APL_Options' ); + $options = get_option( 'apl_options' ); // STEP 2. if ( true === $options['delete_core_db'] || ( false !== $options && ! isset( $options['delete_core_db'] ) ) ) { - delete_option( 'APL_Options' ); - delete_option( 'APL_preset_db-default' ); - } + delete_option( 'apl_options' ); + + // POST LIST POST DATA. + $pl_args = array( + 'post_type' => 'apl_post_list', + 'posts_per_page' => -1, + 'post_status' => array( + 'draft', + 'pending', + 'publish', + 'future', + 'private', + 'trash', + ), + ); + $pl_query = new WP_Query( $pl_args ); + $post_list_data = $pl_query->posts; + + foreach ( $post_list_data as $v1_pl_post ) { + $apl_post_list = new APL_Post_List( $v1_pl_post->post_name ); + + $apl_post_list->delete_post_list(); + } + unregister_post_type( 'apl_post_list' ); + + // DESIGN POST DATA. + $d_args = array( + 'post_type' => 'apl_design', + 'posts_per_page' => -1, + 'post_status' => array( + 'draft', + 'pending', + 'publish', + 'future', + 'private', + 'trash', + ), + ); + $d_query = new WP_Query( $d_args ); + $design_data = $d_query->posts; + + foreach ( $design_data as $v1_d_post ) { + $apl_design = new APL_Design( $v1_d_post->post_name ); + + $apl_design->delete_design(); + } + unregister_post_type( 'apl_design' ); + }// End if(). } /** - * Summary. + * WP Plugin Uninstall * * Handles the uninstall method when plugin is uninstalled. * - * STEP 1 - Delete APLOptions/Core settings from WordPress. - * STEP 2 - Delete preset database options. - * * @since 0.1.0 * @since 0.2.0 - Changed to delete all plugin data, whether 'delete plugin * data upon deactivation' is set or not. + * @since 0.4.0 - Changed to delete Post Data. * @access public */ - public function hook_uninstall() { - // Step 1. - delete_option( 'APL_Options' ); - // Step 2. - // Alt uninstall that uses the 'delete upon deactivation' setting. - delete_option( 'APL_preset_db-default' ); - } - - /** - * Summary. - * - * Gets APLOptions from WordPress database and send the option data back if any. - * - * STEP 1 - Get APLOptions from WordPress Database or get false if options - * doesn't exist. - * STEP 2 - If Options exists, then return object. Otherwise return false. - * - * @since 0.1.0 - * @access private - * - * @see Function/method/class relied on - * @link URL - * - * @return object APL option settings. - */ - private function apl_options_load() { - // New Name ( get_options ). - // Step 1. - $options = get_option( $this->_option_name ); + public static function uninstall() { + delete_option( 'apl_options' ); + + // POST LIST POST DATA. + $pl_args = array( + 'post_type' => 'apl_post_list', + 'posts_per_page' => -1, + 'post_status' => array( + 'draft', + 'pending', + 'publish', + 'future', + 'private', + 'trash', + ), + ); + $pl_query = new WP_Query( $pl_args ); + $post_list_data = $pl_query->posts; + + foreach ( $post_list_data as $v1_pl_post ) { + $apl_post_list = new APL_Post_List( $v1_pl_post->post_name ); + + $apl_post_list->delete_post_list(); + } + unregister_post_type( 'apl_post_list' ); + + // DESIGN POST DATA. + $d_args = array( + 'post_type' => 'apl_design', + 'posts_per_page' => -1, + 'post_status' => array( + 'draft', + 'pending', + 'publish', + 'future', + 'private', + 'trash', + ), + ); + $d_query = new WP_Query( $d_args ); + $design_data = $d_query->posts; - // Step 2. - if ( false !== $options ) { - return $options; - } else { - return $this->apl_options_default(); - } - } + foreach ( $design_data as $v1_d_post ) { + $apl_design = new APL_Design( $v1_d_post->post_name ); - /** - * Summary. - * - * Description. - * - * STEP 1 - If option data (param) exists, save option data to - * WordPress database. - * - * @since 0.1.0 - * @access private - * - * @see Function/method/class relied on - * @link URL - * - * @param object $options Core option settings. - */ - private function apl_options_save( $options ) { - // New name ( set_options ). - // STEP 1. - if ( isset( $options ) ) { - update_option( $this->_option_name, $options ); + $apl_design->delete_design(); } + unregister_post_type( 'apl_design' ); } /** - * Summary. + * (DEPRECATED) Option Defaults * - * Sets options to default values. + * Sets options to default values. Deprecated. * * STEP 1 - Set options as an array. * STEP 2 - Add default values to options. * STEP 3 - Return Options. * * @since 0.1.0 + * @deprecated 0.4.0 Use apl_options_default() + * @see apl_options_default() * @access private * * @return object Core option settings @@ -610,1192 +573,93 @@ private function apl_options_default() { // Step 1. $options = array(); // Step 2. - $options['version'] = APL_VERSION; - $options['preset_db_names'] = array( 'default' ); - $options['delete_core_db'] = true; - $options['jquery_ui_theme'] = 'overcast'; - $options['default_exit'] = false; - $options['default_exit_msg'] = '

        Sorry, but no content is available at this time.

        '; - $options['error'] = ''; + $options['version'] = APL_VERSION; + $options['delete_core_db'] = false; + $options['default_empty_enable'] = false; + $options['default_empty_output'] = '

        ' . __( 'Sorry, but no content is available at this time.', 'advanced-post-list' ) . '

        '; // Step 3. return $options; } /** - * Summary. - * - * Adds the plugins widget to WordPress. - * - * STEP 1 - Register widget. - * - * @since 0.1.0 - * - * @see APL_Widget class 'advanced-post-list/includes/class/class-apl-widget.php - * @link URL - */ - public function hook_action_widget_init() { - register_widget( 'APL_Widget' ); - } - - /** - * Admin Menu. + * (DEPRECATED) APL Load Option * - * Adds the plugin's menu links to the WordPress. + * Gets APLOptions from WordPress database and send the option data back + * if any. Deprecated. * - * STEP 1 - Add a submenu to WordPress settings menu. - * STEP 2 - Add action scripts to that menu page. - * - * @todo create APL's own menu once addition pages are available + * STEP 1 - Get APLOptions from WordPress Database or get false if options + * doesn't exist. + * STEP 2 - If Options exists, then return object. Otherwise return false. * * @since 0.1.0 + * @deprecated 0.4.0 Use apl_options_load() + * @see apl_options_load() + * @access private * * @see Function/method/class relied on * @link URL - */ - public function hook_action_admin_menu() { - // STEP 1. - $apl_admin_page_hook = add_submenu_page( - 'options-general.php', - 'Advanced Post List', - 'Advanced Post List', - 'manage_options', - 'advanced-post-list', - array( $this, 'admin_page' ) - ); - // STEP 2. - add_action( - 'admin_print_styles-' . $apl_admin_page_hook, - array( $this, 'admin_head' ) - ); - // add_filter( 'contextual_help', 'kalinsPost_contextual_help', 10, 3 ); - } - - /** - * Admin Header. - * - * Admin head section that is loaded before the body, and carries scripts - * and styles that are normally loaded before the body content. * - * STEP 1 - Add JS files to WordPress script queue list. - * STEP 2 - Add CSS files to WordPress script queue list. - * STEP 3 - Get Preset Database data. - * STEP 4 - Get Post Type and Taxonomy structure. - * STEP 5 - Get Taxonomy and Terms structure. - * STEP 6 - Get Pages for selecting a parent page, and set them in a hierarchical fashion. - * STEP 7 - Store data in variables. - * STEP 8 - Send variables to script. - * - * @since 0.1.0 - * @since 0.3.0 - Added functions to queue scripts and styles on WordPress. - * - * @see APL_Preset_Db Class - * @see Function/method/class relied on - * @link URL + * @return object APL option settings. */ - public function admin_head() { + private function apl_options_load() { + // New Name ( get_options ). // Step 1. - /***** ADD SCRIPTS TO QUEUE LIST *****/ - wp_enqueue_script( 'apl-admin-js' ); - wp_enqueue_script( 'apl-admin-ui-js' ); - wp_enqueue_script( 'apl-jquery-ui-multiselect-js' ); - wp_enqueue_script( 'apl-jquery-ui-multiselect-filter-js' ); - - // Step 2. - /***** ADD STYLES TO QUEUE LIST *****/ - - wp_enqueue_style( 'apl-admin-css' ); - wp_enqueue_style( 'apl-admin-ui-css' ); - wp_enqueue_style( 'apl-jquery-ui-multiselect-css' ); - wp_enqueue_style( 'apl-jquery-ui-multiselect-filter-css' ); - - // Step 3. - /***** GET AND STORE PLUGIN DATA *****/ - $preset_db = new APL_Preset_Db( 'default' ); - // Step 4. - $post_type_taxonomies = $this->apl_get_post_types( array( 'taxonomies' ) ); - // Step 5. - $tax_terms = $this->apl_get_taxonomies( '', array( 'terms' ) ); - // Step 6. - $post_type_hierarchical = $this->apl_get_post_types( array( 'hierarchical' ) ); - - $post_types = $this->apl_get_post_types(); - - // Step 7. - $apl_admin_settings = array( - 'plugin_url' => APL_URL, - 'savePresetNonce' => wp_create_nonce( 'APL_handler_save_preset' ), - 'deletePresetNonce' => wp_create_nonce( 'APL_handler_delete_preset' ), - 'restorePresetNonce' => wp_create_nonce( 'APL_handler_restore_preset' ), - 'exportNonce' => wp_create_nonce( 'APL_handler_export' ), - 'importNonce' => wp_create_nonce( 'APL_handler_import' ), - 'saveSettingsNonce' => wp_create_nonce( 'APL_handler_save_settings' ), - 'presetDb' => json_encode( (array) $preset_db->_preset_db ), - 'postTax' => $post_type_taxonomies, - 'taxTerms' => $tax_terms, - ); - $apl_admin_ui_settings = array( - //'post_type_amount' => sizeof((array) $post_taxonomies), - 'post_types' => $post_types, - 'postTax_parent_selector' => $post_type_hierarchical, - 'postTax' => $post_type_taxonomies, - 'taxTerms' => $tax_terms, - ); - - // Step 8. - /***** SEND PLUGIN DATA TO SCRIPTS *****/ - wp_localize_script( 'apl-admin-js', 'apl_admin_settings', $apl_admin_settings ); - wp_localize_script( 'apl-admin-ui-js', 'apl_admin_ui_settings', $apl_admin_ui_settings ); - } - - /* - * - * @param array $param1 - * array( - * 0 => labels, - * 1 => labels->singular_name, - * 2 => hierarchical, - * 3 => taxonomies //may add extra support to get other varibles. For now - * // I'll just add the names as the default has it. - stdClass Object - ( - [labels] => stdClass Object( - [name] => string - [singular_name] => string - [add_new] => string - [add_new_item] => string - [edit_item] => string - [new_item] => string - [view_item] => string - [search_items] => string - [not_found] => string - [not_found_in_trash] => string - [parent_item_colon] => - [all_items] => string - [menu_name] => string - [name_admin_bar] => string - ) - [description] => string - [publicly_queryable] => boolean - [exclude_from_search] => boolean - [capability_type] => string - [map_meta_cap] => boolean - [_builtin] => boolean - [_edit_link] => string - [hierarchical] => boolean - [public] => boolean - [rewrite] => boolean - [has_archive] => boolean - [query_var] => boolean - [register_meta_box_cb] => Null - [taxonomies] => Array( - (CHANGED) - Gets taxonomy Attributes - ) - [show_ui] => boolean - [menu_position] => Null - [menu_icon] => Null - [permalink_epmask] => int - [can_export] => boolean - [show_in_nav_menus] => boolean - [show_in_menu] => boolean - [show_in_admin_bar] => boolean - [name] => string - [cap] => stdClass Object( - [edit_post] => string - [read_post] => string - [delete_post] => string - [edit_posts] => string - [edit_others_posts] => string - [publish_posts] => string - [read_private_posts] => string - [read] => string - [delete_posts] => string - [delete_private_posts] => string - [delete_published_posts] => string - [delete_others_posts] => string - [edit_private_posts] => string - [edit_published_posts] => string - ) - [label] => string - ) - */ - /** - * Get Post Types. - * - * Get post type object variables by attr_names array. - * - * @since 0.3.0 - * @access private - * - * @see get_post_type_object() is located in wp-includes/post.php. - * @link https://codex.wordpress.org/Function_Reference/get_post_type_object - * - * @param array $attr_names Array keys to return. - * @return object Post Type objects. - */ - private function apl_get_post_types( $attr_names = array() ) { - $rtn_obj = array(); + $options = get_option( $this->_option_name ); - $post_type_names = get_post_types( '', 'names' ); // Step 2. - $skip_post_types = array( 'attachment', 'revision', 'nav_menu_item' ); - foreach ( $skip_post_types as $post_type_name ) { - unset( $post_type_names[ $post_type_name ] ); - } - unset( $post_type_name ); - unset( $skip_post_types ); - - if ( empty( $attr_names ) ) { - return $post_type_names; - } - - foreach ( $post_type_names as $post_type_name ) { - $rtn_obj[ $post_type_name ] = new stdClass(); - if ( ! empty( $attr_names ) ) { - $post_type_object = get_post_type_object( $post_type_name ); - - foreach ( $attr_names as $attr_name ) { - $delimiter_pos = strpos( $attr_name, '->' ); - if ( false !== $delimiter_pos ) { - $attr_name_dereference = substr( $attr_name, ( $delimiter_pos + 2 ) ); - $attr_name = substr( $attr_name, 0, $delimiter_pos ); - } - unset( $delimiter_pos ); - - switch ( $attr_name ) { - case 'posts': - break; - case 'taxonomies': - if ( ! empty( $attr_name_dereference ) ) { - $terms_delimeter_pos_start = strpos( $attr_name_dereference, 'terms->[' ); - if ( false !== $terms_delimeter_pos_start ) { - $terms_delimeter_pos_length = strpos( $attr_name_dereference, '"]"' ); - $terms_delimeter_pos_length += 2; - $terms_delimeter_pos_length -= $terms_delimeter_pos_start; - - $terms_attr_names = substr( - $attr_name_dereference, - $terms_delimeter_pos_start, - $terms_delimeter_pos_length - ); - - $attr_name_dereference = substr_replace( - $attr_name_dereference, - 'terms', - $terms_delimeter_pos_start, - $terms_delimeter_pos_length - ); - - $taxonomies_attr = json_decode( $attr_name_dereference ); - foreach ( $taxonomies_attr as &$taxonomies_attr_name ) { - if ( 'terms' === $taxonomies_attr_name ) { - $taxonomies_attr_name = $terms_attr_names; - } - } - } else { - $taxonomies_attr = json_decode( $attr_name_dereference ); - } - - $rtn_obj[ $post_type_name ]->$attr_name = APL_Core::apl_get_taxonomies( $post_type_name, $taxonomies_attr ); - unset( $attr_name_dereference ); - } else { - $rtn_obj[ $post_type_name ]->$attr_name = APL_Core::apl_get_taxonomies( $post_type_name, '' ); - } - break; - case 'labels': - if ( ! empty( $attr_name_dereference ) ) { - $rtn_obj[ $post_type_name ]->$attr_name->$attr_name_dereference = $post_type_object->$attr_name->$attr_name_dereference; - unset( $attr_name_dereference ); - } else { - $rtn_obj[ $post_type_name ]->$attr_name = $post_type_object->$attr_name; - } - break; - case 'cap': - if ( ! empty( $attr_name_dereference ) ) { - $rtn_obj[ $post_type_name ]->$attr_name->$attr_name_dereference = $post_type_object->$attr_name->$attr_name_dereference; - unset( $attr_name_dereference ); - } else { - $rtn_obj[ $post_type_name ]->$attr_name = $post_type_object->$attr_name; - } - break; - default: - $rtn_obj[ $post_type_name ]->$attr_name = $post_type_object->$attr_name; - break; - }// End switch(). - }// End foreach(). - unset( $attr_name ); - unset( $post_type_object ); - }// End if(). - }// End foreach(). - unset( $post_type_name ); - - return $rtn_obj; - } - - /* - stdClass Object - ( - [hierarchical] => boolean - [update_count_callback] => string - [rewrite] => array() - [query_var] => string - [public] => boolean - [show_ui] => boolean - [show_tagcloud] => boolean - [_builtin] => boolean - [labels] => stdClass Object - ( - [name] => string - [singular_name] => string - [search_items] => string - [popular_items] => - [all_items] => string - [parent_item] => string - [parent_item_colon] => string - [edit_item] => string - [view_item] => string - [update_item] => string - [add_new_item] => string - [new_item_name] => string - [separate_items_with_commas] => - [add_or_remove_items] => - [choose_from_most_used] => - [menu_name] => string - [name_admin_bar] => string - ) - [show_in_nav_menus] => boolean - [cap] => stdClass Object - ( - [manage_terms] => string - [edit_terms] => string - [delete_terms] => string - [assign_terms] => string - ) - [name] => string - [object_type] => Array() - [label] => string - [terms] => Array() (ADDED) - Can return terms plus attributes. - ) - */ - /** - * Get Taxonomies. - * - * Get taxonomy object variables by attr_names array. - * - * @since 0.3.0 - * @access private - * - * @see $this->apl_get_terms - * @link https://codex.wordpress.org/Function_Reference/get_taxonomy - * - * @param string $post_type_name Optional. Post type taxonomies belong to. - * @param array $attr_names Optional. Array keys to return. - * @return object Taxonomies. - */ - private function apl_get_taxonomies( $post_type_name = '', $attr_names = array() ) { - $rtn_arr = array(); - if ( ! empty( $post_type_name ) ) { - $taxonomy_names = array(); - $taxonomy_names = get_object_taxonomies( $post_type_name ); - $rtn_arr = array(); - foreach ( $taxonomy_names as $taxonomy_name ) { - $rtn_arr[ $taxonomy_name ] = $taxonomy_name; - } - $taxonomy_names = $rtn_arr; - unset( $taxonomy_name ); - unset( $rtn_arr ); + if ( false !== $options ) { + return $options; } else { - $taxonomy_names = get_taxonomies( '', 'names' ); - } - $skip_taxonomies = array( 'post_format', 'nav_menu', 'link_category' ); - foreach ( $skip_taxonomies as $value ) { - unset( $taxonomy_names[ $value ] ); + $defaults = $this->apl_options_default(); + $this->apl_options_save( $defaults ); + return $defaults; } - unset( $skip_taxonomies ); - unset( $value ); - - if ( empty( $attr_names ) ) { - return $taxonomy_names; - } - foreach ( $taxonomy_names as $taxonomy_name ) { - - $rtn_arr[ $taxonomy_name ] = new stdClass(); - - if ( ! empty( $attr_names ) ) { - $taxonomy_object = get_taxonomy( $taxonomy_name ); - - foreach ( $attr_names as $attr_name ) { - $delimiter_pos = strpos( $attr_name, '->' ); - if ( false !== $delimiter_pos ) { - $attr_name_dereference = substr( $attr_name, ( $delimiter_pos + 2 ) ); - $attr_name = substr( $attr_name, 0, $delimiter_pos ); - } - unset( $delimiter_pos ); - - switch ( $attr_name ) { - case 'terms': - if ( ! empty( $attr_name_dereference ) ) { - $rtn_arr[ $taxonomy_name ]->$attr_name = $this->apl_get_terms( $taxonomy_name, json_decode( $attr_name_dereference ) ); - } else { - $rtn_arr[ $taxonomy_name ]->$attr_name = $this->apl_get_terms( $taxonomy_name ); - } - break; - case 'labels': - if ( ! empty( $attr_name_dereference ) ) { - //$rtn_arr[ $taxonomy_name ]->$attr_name = new stdClass(); - $rtn_arr[ $taxonomy_name ]->$attr_name->$attr_name_dereference = $taxonomy_object->$attr_name->$attr_name_dereference; - unset( $attr_name_dereference ); - } else { - $rtn_arr[ $taxonomy_name ]->$attr_name = $taxonomy_object->$attr_name; - } - break; - case 'cap': - if ( ! empty( $attr_name_dereference ) ) { - //$rtn_arr[ $taxonomy_name ]->$attr_name = new stdClass(); - $rtn_arr[ $taxonomy_name ]->$attr_name->$attr_name_dereference = $taxonomy_object->$attr_name->$attr_name_dereference; - unset( $attr_name_dereference ); - } else { - $rtn_arr[ $taxonomy_name ]->$attr_name = $taxonomy_object->$attr_name; - } - break; - default: - $rtn_arr[ $taxonomy_name ]->$attr_name = $taxonomy_object->$attr_name; - break; - } - }// End foreach(). - unset( $attr_name ); - }// End if(). - }// End foreach(). - unset( $taxonomy_name ); - - return $rtn_arr; } - /* - stdClass Object - ( - [term_id] => string //TODO CHANGE TO INT - [name] => string - [slug] => string - [term_group] => string //TODO CHANGE TO INT - [term_taxonomy_id] => string - [taxonomy] => string - [description] => string - [parent] => string //TODO CHANGE TO INT - [count] => string //TODO CHANGE TO INT - ) - * - * Taxonomy_Name - * - $default_args = array( - 'number' => (int) '', //The maximum number of terms to return. - 'offset' => (int) '', //The number by which to offset the terms query. - 'include' => (array) array(), //An array, comma- or space-delimited string of term ids to include in the return array. - 'exclude' => (array) array(), //An array, comma- or space-delimited string of term ids to exclude in the return array. - 'exclude_tree' => (array) array(), //NO DOCUMENTATION - 'orderby' => (string) 'id', //Which properties to order by - // 'id', 'count', 'name', 'slug', 'term_group', or 'none' - 'order' => (string) 'ASC', //Which direction to orderby - // 'ASC' or 'DESC' - 'hide_empty' => (boolean) false, //Whether to return terms that haven't been used - 'fields' => (string) 'ids', //Which properties to return - // 'all', 'ids', 'names', or 'count' - 'slug' => (string) '', //Returns terms whose "slug" matches this value. - 'hierarchical' => (boolean) true, //Whether to include terms that have non-empty descendants - 'name__like' => (string) '', //Returned terms' names will begin with the value of 'name__like', case-insensitive. - 'pad_counts' => (boolean) false, //If true, count all of the children along with the $terms. - 'get' => (string) '', //Allow for overwriting 'hide_empty' and 'child_of', which can be done by setting the value to 'all'. - 'child_of' => (int) 0, //Get all descendents of this term. - 'parent' => (int) '', //Get direct children of this term (only terms whose explicit parent is this value). If 0 is passed, only top-level terms are returned. - 'cache_domain' => (string) 'core', //The 'cache_domain' argument enables a unique cache key to be produced when the query produced by get_terms() is stored in object cache. - 'search' => (string) '' //Returned terms' names will contain the value of 'search' case-insensitive. - ); - - */ - /** - * Get Terms. - * - * Get taxonomy object variables by attr_names array. - * - * @since 0.3.0 - * @access private + * (DEPRECATED) Save Options * - * @see get_terms() in wp-includes/taxonomy.php - * @link https://developer.wordpress.org/reference/functions/get_terms/ + * Deprecated. * - * @param string $taxonomy_name Optional. Taxonomy terms belong to. Default. - * @param array $attr_names Optional. Variable keys to return. Default. - * @param array $args Optional. Simular to $attr_names. Default. - * @return object Terms. - */ - private function apl_get_terms( $taxonomy_name = '', $attr_names = array(), $args = array() ) { - $default_args = array( - 'fields' => 'ids', - 'orderby' => 'id', - 'order' => 'ASC', - 'hide_empty' => false, - ); - if ( empty( $taxonomy_name ) ) { - $taxonomy_name = APL_Core::apl_get_taxonomies(); - } - if ( ! empty( $args ) ) { - foreach ( $args as $arg_name => $arg_value ) { - - if ( empty( $attr_names ) && 'fields' === $arg_name ) { - $default_args[ $arg_name ] = $arg_value; - } else { - $default_args[ $arg_name ] = $arg_value; - } - } - unset( $arg_name ); - unset( $arg_value ); - } - $args = $default_args; - unset( $default_args ); - - $terms = get_terms( $taxonomy_name, $args ); - if ( 'ids' === $args['fields'] || 'count' === $args['fields'] ) { - $tmp_terms = array(); - foreach ( $terms as $key => $value ) { - $tmp_terms[ $key ] = intval( $value ); - } - unset( $key ); - unset( $value ); - $terms = $tmp_terms; - unset( $tmp_terms ); - } - - if ( empty( $attr_names ) || 'ids' !== $args['fields'] ) { - return $terms; - } - - $rtn_arr = array(); - - foreach ( $terms as $key => $term ) { - $term_object = get_term( $term, $taxonomy_name ); - - $rtn_arr[ $key ] = new stdClass(); - - if ( ! empty( $attr_names ) ) { - foreach ( $attr_names as $attr_name ) { - if ( ! empty( $attr_name ) && isset( $term_object->$attr_name ) ) { - if ( 'term_id' === $attr_name || - 'term_group' === $attr_name || - 'parent' === $attr_name || - 'count' === $attr_name ) { - $rtn_arr[ $key ]->$attr_name = intval( $term_object->$attr_name ); - } elseif ( isset( $term_object->$attr_name ) ) { - $rtn_arr[ $key ]->$attr_name = $term_object->$attr_name; - } - } - } - unset( $attr_name ); - } - } - unset( $key ); - unset( $term ); - - return $rtn_arr; - } - - /* - $arg_example = array( - 'orderby' => 'title', - 'order' => 'ASC', - 'p' => (int) 0, - 'post_parent' => (int) 0, - 'tax_query' => array( - array( - 'taxonomy' => 'people', - 'field' => 'slug', - 'terms' => 'bob' - ) - ), - 'post_type' => array('post', 'page', 'custom_post_type_01'), //OR - 'post_type' => 'post', - 'nopaging' => true - ); - */ - - /* - array( - 0 => stdClass Object - { - [ID] => int 0 - [post_author] => string '' - [post_date] => string '' - [post_date_gmt] => string '' - [post_content] => string '' - [post_title] => string '' - [post_excerpt] => string '' - [post_status] => string '' - [comment_status] => string '' - [ping_status] => string '' - [post_password] => string '' - [post_name] => string '' - [to_ping] => string '' - [pinged] => string '' - [post_modified] => string '' - [post_modified_gmt] => string '' - [post_content_filtered] => string '' - [post_parent] => int 0 - [guid] => string '' - [menu_order] => int 0 - [post_type] => string '' - [post_mime_type] => string '' - [comment_count] => string '0' - [filter] => string 'raw' - } - ) - */ - /** - * Get Posts. - * - * Get taxonomy object variables by attr_names array. + * STEP 1 - If option data (param) exists, save option data to + * WordPress database. * - * @since 0.3.0 + * @since 0.1.0 + * @deprecated 0.4.0 Use apl_options_save() + * @see apl_options_save() * @access private * - * @see WP_Query class - * @link URL - * - * @param array $attr_names Optional. Description. Default. - * @param array $args Optional. Description. Default. - * @return object Posts. - */ - private function apl_get_posts( $attr_names = array(), $args = array() ) { - $default = array( - 'orderby' => 'ID', - 'order' => 'ASC', - 'post_type' => 'post', - 'nopaging' => true, - ); - - if ( ! empty( $args ) ) { - foreach ( $args as $key => $arg ) { - if ( ! empty( $arg ) ) { - $default[ $key ] = $arg; - } - } - unset( $arg ); - } - $args = $default; - - $apl_query = new WP_Query( $args ); - - $posts = $apl_query->posts; - unset( $apl_query ); - - $rtn_posts = array(); - $attr_names_count = count( $attr_names ); - if ( empty( $attr_names ) ) { - $rtn_posts = array(); - foreach ( $posts as $post ) { - $rtn_posts[ $post->post_name ] = $post->ID; - } - unset( $post ); - unset( $posts ); - return $rtn_posts; - } else { - foreach ( $posts as $post ) { - $rtn_posts[ $post->post_name ] = new stdClass(); - if ( ! empty( $attr_names ) ) { - foreach ( $attr_names as $attr_name ) { - if ( ! empty( $attr_name ) && isset( $post->$attr_name ) ) { - $rtn_posts[ $post->post_name ]->$attr_name = $post->$attr_name; - } - } - unset( $attr_name ); - } - unset( $post ); - } - - unset( $posts ); - return $rtn_posts; - } - } - - /** - * Admin Page. - * - * Admin Page to display. - * - * @since 0.3.0 - */ - public function admin_page() { - // Step 1. - require_once( APL_DIR . 'admin/admin.php' ); - } - - /** - * Summary. - * - * Export Hook function. - * - * STEP 1 - Check AJAX security value. - * STEP 2 - Store default data. - * STEP 3 - Store the filename and url export file location. - * STEP 4 - Echo that in json string. - * - * @since 0.2.0 - * - * @return void JSON string to export. - */ - public function hook_action_ajax_export() { - // Step 1. - check_ajax_referer( 'APL_handler_export' ); - - $rtn_data = new stdClass(); - // Step 2. - $rtn_data->_status = 'success'; - $rtn_data->_error = ''; - - // Step 3. - $rtn_data->filename = $_POST['filename']; - - $preset_db = new APL_Preset_Db( 'default' ); - $temp_export_data = new stdClass(); - $temp_export_data->version = APL_VERSION; - if ( 'database' === $_POST['export_type'] ) { - $temp_export_data->presetDbObj = $preset_db; - } elseif ( 'preset' === $_POST['export_type'] ) { - $preset_name = $_POST['filename']; - $rtn_data->filename = 'APL.' . $preset_name . '.' . date( 'Y-m-d' ); - - $temp_export_data->preset_db = new stdClass(); - $temp_export_data->preset_db->_preset_db = new stdClass(); - - $temp_export_data->preset_db->_preset_db->$preset_name = $preset_db->_preset_db->$preset_name; - } else { - $rtn_data->_status = 'failure'; - $rtn_data->_error = 'No \'Import Type\' selected - Unknown error'; - } - - update_option( 'APL_TMP_export_dataOutput', $temp_export_data ); - - $rtn_data->action = 'APL_export'; - $rtn_data->_ajax_nonce = wp_create_nonce( 'APL_export' ); - - // Step 4. - echo json_encode( $rtn_data ); - } - - // TODO CREATE AN AJAX FUNCTION TO IMPORT DATA TO THE PLUGIN - // COULDN'T FIND A WAY TO CARRY THE $_FILES GLOBAL VARIBLE - // THROUGH .post TO TARGET PHP CODE. - /** - * Summary. - * - * (Un-used) Handles the AJAX function for importing data. Method used when - * jQuery.post is called in javascript for $('#frmImport').submit(). - * - * STEP 1 - Check wp_create_nonce value. - * STEP 2 - Return data (if any) as a JSON string. - * - * @since 0.2.0 - * @since 0.3.0 - Fixed major bugs, added multi-file uploading, better error - * handling. - * - * @see APL_Preset_Db class - * @see APLUpdater - * - * @return void JSON string to import. - */ - public function hook_action_ajax_import() { - check_ajax_referer( 'APL_handler_import' ); - $rtn_data = new stdClass(); - $rtn_data->_msg = 'success'; - $rtn_data->_error = ''; - $rtn_data->_preset_db = new stdClass(); - $rtn_data->overwrite_preset_db = new stdClass(); - - $temp_preset_db = new APL_Preset_Db(); - - if ( 'kalin' === $_POST['import_type'] ) { - // GET KALIN'S POST LIST DATA. - $kalin_preset_db = get_option( 'kalinsPost_admin_options' ); - if ( false === $kalin_preset_db ) { - $rtn_data->_msg = 'failure'; - $rtn_data->_error .= 'Can\'t load Kalin\'s Post List data - Database may be missing or plugin is not installed.
        '; - } else { - // UPGRADE. - $updater = new APLUpdater( 'kalin', $kalin_preset_db ); - if ( null === $updater->presetDbObj ) { - $rtn_data->_msg = 'failure'; - $rtn_data->_error .= 'Can\'t upgrade Kalin\'s Post List - Unknown, may be a currupt data.
        '; - } else { - // MERGE TOGETHER. - foreach ( $updater->presetDbObj->_preset_db as $preset_name => $preset_obj ) { - if ( ! isset( $temp_preset_db->_preset_db->$preset_name ) ) { - $temp_preset_db->_preset_db->$preset_name = $preset_obj; - } - } - } - } - } elseif ( 'file' === $_POST['import_type'] ) { - foreach ( $_FILES as $key => $value ) { - // GET FILE CONTENT. - $file_preset_db[ $key ] = json_decode( file_get_contents( $value['tmp_name'] ) ); - if ( is_null( $file_preset_db[ $key ] ) ) { - $rtn_data->_msg = 'failure'; - $rtn_data->_error .= 'Can\'t load file ' . $value['name'] . ' - Syntax Error with JSON encoding inside file.
        '; - } else { - // UPGRADE. - $updater = new APLUpdater( $file_preset_db[ $key ]->version, $file_preset_db[ $key ]->presetDbObj ); - if ( null === $updater->presetDbObj ) { - $rtn_data->_msg = 'failure'; - $rtn_data->_error .= 'Can\'t upgrade file ' . $value['name'] . ' - Version number is missing, or no preset table was found; may be a currupted file.
        '; - } else { - // MERGE TOGETHER. - foreach ( $updater->presetDbObj->_preset_db as $preset_name => $preset_obj ) { - if ( ! isset( $temp_preset_db->_preset_db->$preset_name ) ) { - $temp_preset_db->_preset_db->$preset_name = $preset_obj; - } - } - } - } - } - } else { - $rtn_data->_msg = 'failure'; - $rtn_data->_error = 'No \'Imput Type\' selected. Choose between either Kalin\'s Post List or upload a file from Advanced Post List'; - }// End if(). - - // LOAD PLUGIN PRESETS. - $preset_db = new APL_Preset_Db( 'default' ); - $overwrite_preset_db = new stdClass(); - // COMPARE PLUGIN DB WITH UPLOAD DATA. - foreach ( $temp_preset_db->_preset_db as $tmp_preset_name => $tmp_preset_value ) { - // ADD MISSING. - if ( ! isset( $preset_db->_preset_db->$tmp_preset_name ) ) { - $preset_db->_preset_db->$tmp_preset_name = $tmp_preset_value; - } else { - // ADD TO CONFIRM OVERWRITE LIST {OBJECT}. - $overwrite_preset_db->$tmp_preset_name = $tmp_preset_value; - } - } - - // SEND UPDATED AND POSSIBLE OVERWRITES TO UPDATE THE PRESET TABLE IN JS. - $rtn_data->_preset_db = $preset_db->_preset_db; - $rtn_data->overwrite_preset_db = $overwrite_preset_db; - - // STORE TEMP PRESET DATABASE OBJECT TO BE USED IN import.php. - // DO NOT SAVE HERE - SAVE IN FINAL IMPORT @ import.php. - // JUST A NOTE FOR FUTURE MODIFICATIONS. - update_option( 'APL_TMP_import_presetDbObj', $temp_preset_db ); - - // CREATE NEW AJAX NONCE VALUES. - $rtn_data->action = 'APL_import'; - $rtn_data->_ajax_nonce = wp_create_nonce( 'APL_import' ); - - echo json_encode( $rtn_data ); - } - - /** - * Summary. - * - * Method used for saving APL core 'General Settings' to the developer's - * WordPress database. - * - * STEP 1 - Check AJAX wp_create_nonce security value. - * STEP 2 - Load APL Options. - * STEP 3 - Store 'delete core db' value. - * STEP 4 - Store jQuery UI Theme value and queue the style. - * STEP 5 - Save APLOptions to database. - * STEP 6 - Set Theme value in return variable. - * STEP 7 - Echo JSON string to jQuery.post param function. - * - * @since 0.2.0 - * @since 0.3.0 - Added JQuery UI Theme setting. - * * @see Function/method/class relied on * @link URL * - * @return void JSON string to return to AJAX. - */ - public function hook_action_ajax_save_settings() { - // Step 1. - $check_ajax_referer = check_ajax_referer( 'APL_handler_save_settings' ); - - $rtn_data = new stdClass(); - $rtn_data->error = ''; - $rtn_data->theme = 'overcast'; - - // Step 2. - $options = $this->apl_options_load(); - - // Step 3. - //$options['delete_core_db'] = $_POST['deleteDb']; - $options['delete_core_db'] = false; - if ( 'true' === $_POST['deleteDb'] ) { - $options['delete_core_db'] = true; - } - - // Step 4. - $options['jquery_ui_theme'] = $_POST['theme']; - wp_enqueue_style( - 'apl-admin-ui-css', - 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/themes/' . $options['jquery_ui_theme'] . '/jquery-ui.css', - false, - APL_VERSION, - false - ); - - $options['default_exit'] = false; - if ( 'true' === $_POST['defaultExit'] ) { - $options['default_exit'] = true; - } - $options['default_exit_msg'] = stripslashes( $_POST['defaultExitMsg'] ); - - // Step 5. - $this->apl_options_save( $options ); - - // Step 6. - $rtn_data->theme = $options['jquery_ui_theme']; - - // Step 7. - echo json_encode( $rtn_data ); - } - - /** - * Summary. - * - * Saves the created preset data from the APL Admin page. - * - * STEP 1 - Check javascript ajax wp_create_nonce reference. - * STEP 2 - Store preset name. - * STEP 3 - Store preset's post parents, if any. - * STEP 4 - Process and store the Post Type & Taxonomy structure. - * STEP 5 - Store the preset's number of posts. - * STEP 6 - Store the order values. - * STEP 7 - Store the post status. - * STEP 8 - Store the exclude current boolean. - * STEP 9 - Store the Before, Content, & After HTML/JavaScript/Shortcode content. - * STEP 10 - Overwrite or save the preset. - * STEP 11 - Create and store data for the varible returned to the AJAX function. - * STEP 12 - echo the data returned though a json_encode method. - * - * @since 0.1.0 - * @since 0.3.0 - Added custom post type & taxonomy support. Changed post - * parent from one selection to multiple selections, and - * get other pages from multiple hierarchical post types. - * Along with the Post Status setting. - * - * @see APL_Preset_Db class - * @see APL_Preset class - * @link URL - * - * @return void JSON string to return to AJAX. + * @param object $options Core option settings. */ - public function hook_action_ajax_save_preset() { - // TODO - Create a function to decode preset, and/or handle postTax structure. - // TODO - Change to filter_input() instead of $_POST http://php.net/manual/en/function.filter-input.php . - // Step 1. - check_ajax_referer( 'APL_handler_save_preset' ); - - // DEFAULT USE. - $preset_db = new APL_Preset_Db( 'default' ); - // MULTI PRESET OPTIONS. - /* - foreach ($options['preset_db_names'] as $key => $value) - { - $preset_db[$key] = $value; - } - */ - - // Step 2. - $preset_name = stripslashes( $_POST['presetName'] ); - - $preset_obj = new APL_Preset(); - - // Step 3. - $preset_obj->_postParents = json_decode( stripslashes( $_POST['postParents'] ) ); - $preset_obj->_postParents = array_unique( $preset_obj->_postParents ); - - // Step 4. - $preset_obj->_postTax = json_decode( stripslashes( $_POST['postTax'] ) ); - $temp_post_tax = new stdClass(); - foreach ( $preset_obj->_postTax as $post_type_name => $post_type_value ) { - foreach ( $post_type_value->taxonomies as $taxonomy_name => $taxonomy_value ) { - if ( ! is_object( $temp_post_tax->$post_type_name ) ) { - $temp_post_tax->$post_type_name = new stdClass(); - } - if ( ! is_object( $temp_post_tax->$post_type_name->taxonomies ) ) { - $temp_post_tax->$post_type_name->taxonomies = new stdClass(); - } - $temp_post_tax->$post_type_name->taxonomies->$taxonomy_name = new stdClass(); - - $temp_post_tax->$post_type_name->taxonomies->$taxonomy_name->require_taxonomy = $taxonomy_value->require_taxonomy; - $temp_post_tax->$post_type_name->taxonomies->$taxonomy_name->require_terms = $taxonomy_value->require_terms; - $temp_post_tax->$post_type_name->taxonomies->$taxonomy_name->include_terms = $taxonomy_value->include_terms; - - $temp_post_tax->$post_type_name->taxonomies->$taxonomy_name->terms = array(); - foreach ( $taxonomy_value->terms as $term_index => $term_value ) { - $temp_post_tax->$post_type_name->taxonomies->$taxonomy_name->terms[ $term_index ] = intval( $term_value ); - } - } - } - $preset_obj->_postTax = $temp_post_tax; - - // Step 5. - // (int) howmany to display. - $preset_obj->_listCount = intval( $_POST['count'] ); - - // Step 6. - // (string) - $preset_obj->_listOrder = $_POST['order']; - // (string) - $preset_obj->_listOrderBy = $_POST['orderBy']; - - // Step 7. - // (array) => (string) - $preset_obj->_postVisibility = json_decode( stripslashes( $_POST['postVisibility'] ) ); - // (array) => (string) - $preset_obj->_postStatus = json_decode( stripslashes( $_POST['postStatus'] ) ); - // (string) - $preset_obj->_userPerm = $_POST['userPerm']; - - // (string) - $preset_obj->_postAuthorOperator = $_POST['authorOperator']; - // (array) => (int) - $preset_obj->_postAuthorIDs = json_decode( stripslashes( $_POST['authorIDs'] ) ); - - // (boolean) - $preset_obj->_listIgnoreSticky = true; - if ( 'false' === $_POST['ignoreSticky'] ) { - $preset_obj->_listIgnoreSticky = false; - } - - // Step 8 - // (boolean) - $preset_obj->_listExcludeCurrent = true; - if ( $_POST['excludeCurrent'] === 'false' ) { - $preset_obj->_listExcludeCurrent = false; - } - - // (boolean) - $preset_obj->_listExcludeDuplicates = true; - if ( 'false' === $_POST['excludeDuplicates'] ) { - $preset_obj->_listExcludeDuplicates = false; - } - - $tmp_exclude_posts = array(); - $preset_obj->_listExcludePosts = array(); - // (array) => (int) - $tmp_exclude_posts = json_decode( stripslashes( $_POST['excludePosts'] ) ); - foreach ( $tmp_exclude_posts as $post_id ) { - if ( ! empty( $post_id ) ) { - $preset_obj->_listExcludePosts[] = intval( $post_id ); - } + private function apl_options_save( $options ) { + // New name ( set_options ). + // STEP 1. + if ( isset( $options ) ) { + update_option( $this->_option_name, $options ); } - $preset_obj->_listExcludePosts = array_unique( $preset_obj->_listExcludePosts ); - - // Step 9. - // (string) - $preset_obj->_exit = stripslashes( $_POST['exit'] ); - $preset_obj->_before = stripslashes( $_POST['before'] ); - $preset_obj->_content = stripslashes( $_POST['content'] ); - $preset_obj->_after = stripslashes( $_POST['after'] ); - - // Step 10. - $preset_db->_preset_db->$preset_name = $preset_obj; - $preset_db->options_save_db(); - - // Step 11. - $rtn_data = new stdClass(); - $rtn_data->status = 'success'; - $rtn_data->preset_arr = $preset_db->_preset_db; - $rtn_data->previewOutput = $this->display_post_list( $preset_name ); - - // Step 12. - echo json_encode( $rtn_data ); } /** - * Summary. - * - * Method handler for deleting presets within the Preset DbOptions. + * Widget Initialization * - * STEP 1 - Check JavaScript AJAX wp_create_nonce reference. - * STEP 2 - Load APL Preset DbOptions. - * STEP 3 - Get postname from page - * STEP 4 - Delete (unset) preset from preset database variable. - * STEP 5 - Save preset database. - * STEP 6 - echo preset database. + * Registers the Plugin's Widget to WordPress. * * @since 0.1.0 * - * @see APL_Preset_Db class - * @link URL - * @global type $varname Description. - * @global type $varname Description. - * - * @return void JSON string to return to AJAX. - */ - public function hook_action_ajax_delete_preset() { - // Step 1. - check_ajax_referer( 'APL_handler_delete_preset' ); - - // Step 2. - $preset_db = new APL_Preset_Db( 'default' ); - - // Step 3. - $preset_name = stripslashes( $_POST['preset_name'] ); - - // Step 4. - unset( $preset_db->_preset_db->$preset_name ); - - // Step 5. - $preset_db->options_save_db(); - - // Step 6. - echo json_encode( $preset_db->_preset_db ); - } - - /** - * Summary. - * - * Method handler for restoring the original plugin preset defaults - * - * STEP 1 - Grab the JavaScript AJAX reference. - * STEP 2 - Get preset options for a temp and a current variable. - * STEP 3 - Set temp to default preset_database_object. - * STEP 4 - Add default presets to current preset_database_object. - * STEP 5 - Save current preset database variable. - * STEP 6 - Echo/Return preset values. - * - * @since 0.1.0 - * - * @see APL_Preset_Db class - * @link URL - * - * @return void JSON string to return to AJAX. + * @see APL_Widget class 'advanced-post-list/includes/class/class-apl-widget.php + * @link https://developer.wordpress.org/themes/functionality/widgets/ + * @link https://codex.wordpress.org/Function_Reference/register_widget */ - public function hook_action_ajax_restore_preset() { - // STEP 1. - check_ajax_referer( 'APL_handler_restore_preset' ); - - // STEP 2. - $preset_db = new APL_Preset_Db( 'default' ); - $temp_db = new APL_Preset_Db( 'default' ); - - // STEP 3. - $temp_db->set_to_defaults(); - - // STEP 4. - foreach ( $temp_db->_preset_db as $key => $value ) { - $preset_db->_preset_db->$key = $value; - } - - // STEP 5. - $preset_db->options_save_db(); - - // STEP 6. - echo json_encode( $preset_db->_preset_db ); + public function action_widget_init() { + register_widget( 'APL_Widget' ); } /** - * Summary. + * Shortcode [Post_List] * * Method handler for 'post_list' shortcode and displaying the target post list. * @@ -1808,11 +672,13 @@ public function hook_action_ajax_restore_preset() { * @param string $att Carries the preset name. * @return string HTML content, if param is set. Otherwise return an empty string. */ - public function hook_shortcode_post_list( $att ) { + public function shortcode_post_list( $att ) { // STEP 1. if ( isset( $att['name'] ) ) { // STEP 2. return $this->display_post_list( $att['name'] ); + } elseif ( current_user_can( 'manage_options' ) ) { + return esc_html__( 'NOTICE: Shortcode name is missing. Ex [post_list name=\'example\']', 'advanced-post-list' ); } else { // STEP 3. return ''; @@ -1820,210 +686,130 @@ public function hook_shortcode_post_list( $att ) { } /** - * Summary. + * Public Hard-code Display Post List * - * Public function for post lists. - * - * @since 0.1.0 - * @access (for functions: only use if private) + * Public function for displaying Post Lists. * - * @see Function/method/class relied on - * @link URL - * @global type $varname Description. - * @global type $varname Description. + * @since 0.3.0 + * @since 0.4.0 - Added slug sanitization. * * @param string $preset_name Preset slug/name. - * @return string HTML content + * @return string HTML content. */ public function display_post_list( $preset_name ) { - require_once( APL_DIR . 'includes/class/class-apl-shortcodes.php' ); - - return $this->apl_run( $preset_name ); + $preset_name = sanitize_key( $preset_name ); + return $this->post_list_loop( $preset_name ); } /** - * Summary. - * - * Method used for executing the main purpose of the plugin. Creates an HTML - * post list string to be sent to the page that it was called from. What is - * displayed is determined by the 'post_list name' being used. - * - * STEP 1 - Get the preset object, and if empty, display a message to - * the admin. - * STEP 2 - If Exclude Duplicates (w/ multiple post lists) is checked, - * then add any post IDs collected to the preset post list object's exclude - * post array to be filter out. - * STEP 3 - Initialize the APLQuery object (sets the query strings). - * STEP 4 - Query the posts to retrieve the final WP_Query class. - * STEP 5 - If posts are present, the use the loop to display posts. Otherwise - * return an exit message if no posts are found. - * STEP 6 - Return output string. + * Post List Looper * + * Method used for executing the frontend loop. Currently uses an output + * string (HTML) to return. + * + * @ignore * @since 0.1.0 - * @since 0.2.0 - Corrected a typo in the if statement for _postExcludeCurrent. + * @since 0.2.0 - Corrected a typo in the if statement for _postExcludeCurrent. * @since 0.3.b8 - Complete overhaul. Moved dynamic settings to APLQuery, - * implemented WP's loop. + * implemented WP's loop. + * @since 0.4.0 - Changed 'Preset' database objects to APL_Post_List + * and APL_Design database objects. * @access private * - * @see APL_Preset_Db class + * @see APL_Post_List class + * @see APL_Design class * @see APL_Query class * @see APL_Internal_Shortcodes class - * @link URL * * @param string $preset_name Preset slug/name. * @return string HTML string. */ - private function apl_run( $preset_name ) { - // What does this do??? - // This is something that Kalin was originally had in mind for - // implementing page style and design with the global $post. - /* - if ($newVals->post_type == "none") { - $output = APLInternalShortcodeReplace($newVals->content, $post, 0); - } - */ - - // STEP 1 - Get the preset object, and if empty, display a message - // to the admin. - $preset_db_obj = new APL_Preset_Db( 'default' ); - if ( isset( $preset_db_obj->_preset_db->$preset_name ) ) { - $preset_obj = new APL_Preset(); - $preset_obj = $preset_db_obj->_preset_db->$preset_name; + private function post_list_loop( $post_list_slug ) { + // STEP 1 - Get Post List data, and if valid, do initilization. + // Otherwise, for Admin show an alert message, and nothing to viewers. + $apl_post_list = new APL_Post_List( $post_list_slug ); + if ( $apl_post_list->id ) { + // INIT. + require_once( APL_DIR . 'includes/class/class-apl-shortcodes.php' ); + $apl_design = new APL_Design( $apl_post_list->pl_apl_design ); } elseif ( current_user_can( 'manage_options' ) ) { - // Alert Message for admins in case an invalid preset was used. - return '

        Admin Alert - A problem has occured. A non-existent preset name has been passed use.

        '; + // Admin Message. + return esc_html__( 'NOTICE: Post list \'name\' does not exist or is invalid.', 'advanced-post-list' ); } else { - // Users/Visitors won't be able to see the post list if the - // preset post list name isn't set right. - return''; + // Users/Visitors. + return ''; } - // STEP 2 - If Exclude Duplicates (w/ multiple post lists) is checked, + // STEP - If Exclude Duplicates is checked (w/ multiple post lists), // then add any post IDs collected to the preset post list object's // exclude post array to be filter out. - if ( isset( $preset_obj->_listExcludeDuplicates ) && true === $preset_obj->_listExcludeDuplicates ) { - foreach ( $this->_remove_duplicates as $post_id ) { - $preset_obj->_listExcludePosts[] = $post_id; + if ( $apl_post_list->pl_exclude_dupes ) { + foreach ( $this->_remove_duplicates as $v1_post_id ) { + $apl_post_list->post__not_in[] = $v1_post_id; } } - // STEP 3 - Initialize the APLQuery object (sets the query strings). - // The constructor will do most of the initial settings, like setting - // multiple query strings according to APL. The class will still need to - // use a public function to return a WP_Query class; until 'inheritance' - // becomes more of a possibility. - $apl_query = new APL_Query( $preset_obj ); + // STEP - Init APL_Query object (sets the query strings). + // The constructor will process and produce a final array of query_args. + // Then APL_Query will need to query_wp and return a final WP_Query class. + // NOTE: Look into class inheritence for enhancing, or change the label + // of the concept; APL_Process, *_Factory. + $apl_query = new APL_Query( $apl_post_list ); - //STEP 4 - Query the posts to retrieve the final WP_Query class. - $wp_query_class = $apl_query->query_wp( $apl_query->_query_str_array ); + // STEP - Query the posts to retrieve the final WP_Query class. + // NOTE: There's got to be a better concept to produce a final WP_Query. + $wp_query_class = $apl_query->query_wp( $apl_query->query_args_arr ); /* ****************************************************************** */ /* * The Loop (APL/WP Concept) ************************************** */ /* ****************************************************************** */ - // STEP 5 - If posts are present, the use the loop to display posts. + // STEP 5 - If there are posts, the use the loop to display posts. // Otherwise return an exit message if no posts are found. + $output = ''; + $count = 0; if ( $wp_query_class->have_posts() ) { - $output = ''; - - /* * Before ***************************************************** */ - $output .= $preset_obj->_before; - - /* * Content **************************************************** */ - $count = 0; + // BEFORE. + $output .= $apl_design->before; + // Initial Internal Shortcodes since there's posts. $internal_shortcodes = new APL_Internal_Shortcodes(); + $output = apply_filters( 'apl_core_loop_before_content', $output, $count, $wp_query_class ); + + // LIST CONTENT. while ( $wp_query_class->have_posts() ) { $wp_query_class->the_post(); - // $APL_post->ID;. - $this->_remove_duplicates[] = $wp_query_class->post->ID; - $output .= $internal_shortcodes->replace( $preset_obj->_content, $wp_query_class->post ); + $this->_remove_duplicates[] = $wp_query_class->post->ID; + $output .= $internal_shortcodes->replace( $apl_design->content, $wp_query_class->post ); $count++; } - + // [final_end] internal shortcode. if ( strrpos( $output, 'final_end' ) ) { $output = $internal_shortcodes->final_end( $output ); } - /* * After ****************************************************** */ - $output .= $preset_obj->_after; + $output = apply_filters( 'apl_core_loop_after_content', $output, $count, $wp_query_class ); + + // AFTER. + $output .= $apl_design->after; + + // Exit method for apl-shortcodes class; __destroy magic method wasn't working as intended. + $internal_shortcodes->remove(); } else { - // if (count($apl_query->_posts) === 0). + // EMPTY. $apl_options = $this->apl_options_load(); - if ( ! empty( $preset_obj->_exit ) ) { - return $preset_obj->_exit; - } elseif ( true === $apl_options['default_exit'] && ! empty( $apl_options['default_exit_msg'] ) ) { - return $apl_options['default_exit_msg']; - } else { - return ''; + + if ( ! empty( $apl_design->empty ) ) { + $output .= $apl_design->empty; + } elseif ( true === $apl_options['default_empty_enable'] && ! empty( $apl_options['default_empty_output'] ) ) { + $output .= $apl_options['default_empty_output']; } }// End if(). - /* Restore Global Post Data */ wp_reset_postdata(); - // Exit method for apl-shortcodes class. - $internal_shortcodes->remove(); - // STEP 6 - Return output string. + // STEP - Return output string. return $output; } - - /** - * Summary. - * - * Get the post values needed for the plugin's. - * - * STEP 1 - Get Global post, current post. - * STEP 2 - Store current post's ID. - * STEP 3 - Store current post's post_type. - * STEP 4 - Get Post Type's Taxonomies. - * STEP 5 - Get Taxonomy's Terms and store them accordingly. - * STEP 6 - Return the data stored. - * - * @since 0.3.0 - * @access private - * - * @global object $post Description. - * - * @return object post_types & taxonomy. - */ - private function apl_get_post_attr() { - $rtn_obj = new stdClass(); - // Step 1. - global $post; - - // Step 2. - $rtn_obj->ID = (int) 0; - if ( isset( $post->ID ) ) { - $rtn_obj->ID = $post->ID; - } - - // Step 3. - $rtn_obj->post_type = ''; - if ( isset( $post->post_type ) ) { - $rtn_obj->post_type = $post->post_type; - } - - // Step 4. - $rtn_obj->taxonomies = new stdClass(); - $taxonomies = $this->apl_get_taxonomies( $rtn_obj->post_type ); - foreach ( $taxonomies as $taxonomy ) { - // Step 5. - if ( isset( $post->ID ) ) { - $terms = wp_get_post_terms( $post->ID, $taxonomy ); - } - - if ( ! empty( $terms ) ) { - // $tmp_terms = array();. - foreach ( $terms as $term_index => $term_object ) { - $rtn_obj->taxonomies->$taxonomy->terms[ $term_index ] = $term_object->term_id; - //$tmp_terms[$term_index] = $term_object->term_id; - } - //$rtn_obj->taxonomies->$taxonomy->terms = $tmp_terms; - } - } - // Step 6. - return $rtn_obj; - } } diff --git a/includes/class/class-apl-design.php b/includes/class/class-apl-design.php new file mode 100644 index 0000000..5e9ae1a --- /dev/null +++ b/includes/class/class-apl-design.php @@ -0,0 +1,374 @@ +slug = sanitize_title_with_dashes( $design_name ); + $this->title = (string) $design_name; + + $args = array( + 'name' => $this->slug, + ); + $this->get_data( $args ); + + if ( is_admin() ) { + // Draft/Init Hook. + + // Save Design Meta Data Hook. + add_action( 'save_post_apl_design', array( &$this, 'hook_action_save_post_apl_design' ), 10, 3 ); + // Delete Design Hook. + // Import / Export Hook. + } + } + + /** + * Get Design data + * + * Gets the design data from the database. + * + * @ignore + * @since 0.4.0 + * @access private + * + * @param array $args Query args for get_posts ( Same as WP_Query ). + * @return boolean Will return false on failure. + */ + private function get_data( $args = array() ) { + $defaults = array( + 'post_type' => 'apl_design', + //'name' => '', + 'post_status' => array( + 'draft', + 'pending', + 'publish', + 'future', + 'private', + 'trash', + ), + 'posts_per_page' => 1, + //'suppress_filters' => true, + ); + $args = wp_parse_args( $args, $defaults ); + + // If there is a design, set this variable to the meta data it has. + // Else no designs stored, return false. + $d_query = new WP_Query( $args ); + if ( 1 > $d_query->post_count ) { + return false; + } + $design = $d_query->post; + + if ( $design->post_name === $args['name'] && ! empty( $args['name'] ) ) { + $this->id = absint( $design->ID ); + $this->title = esc_html( $design->post_title ); + $this->slug = $design->post_name; + + $this->before = get_post_meta( $this->id, 'apl_before', true ) ?: ''; + $this->content = get_post_meta( $this->id, 'apl_content', true ) ?: ''; + $this->after = get_post_meta( $this->id, 'apl_after', true ) ?: ''; + $this->empty = get_post_meta( $this->id, 'apl_empty', true ) ?: ''; + return true; + } else { + return false; + } + } + + /** + * Save APL Design Object + * + * Inserts or updates the Design post data with $this object. + * + * @since 0.4.0 + * @access public + */ + public function save_design() { + if ( empty( $this->slug ) ) { + return; + } + $get_args = array( + 'post__in' => array( $this->id ), + //'name' => $this->slug, + 'post_type' => 'apl_design', + ); + $designs = new WP_Query( $get_args ); + + $save_postarr = array( + 'ID' => $this->id, + 'post_title' => $this->title, + 'post_name' => $this->slug, + 'post_status' => 'publish', + 'post_type' => 'apl_design', + ); + + if ( 1 > $designs->post_count || 0 === $this->id ) { + $this->insert_design_post( $save_postarr ); + } else { + $this->update_design_post( $save_postarr ); + } + } + + /** + * Deletes the Design + * + * @since 0.4.0 + * + * @link https://codex.wordpress.org/Function_Reference/wp_delete_post + */ + public function delete_design() { + + wp_delete_post( $this->id, true ); + + } + + /** + * Insert Design post data + * + * Inserts APL Design's post args to the database to create a new WP_Post. + * + * @ignore + * @since 0.4.0 + * @access private + * + * @param array $args Post arg array for creating Post objects. + */ + private function insert_design_post( $args = array() ) { + $defaults = $this->default_postarr(); + $args = wp_parse_args( $args, $defaults ); + + global $wp_rewrite; + if ( is_null( $wp_rewrite ) ) { + $wp_rewrite = new WP_Rewrite(); + } + + remove_all_actions( 'save_post_apl_design', 10 ); + add_action( 'save_post_apl_design', array( &$this, 'hook_action_save_post_apl_design' ), 10, 3 ); + $old_id = $this->id; + $rtn_post_id = wp_insert_post( $args ); + + if ( defined( 'ICL_SITEPRESS_VERSION' ) ) { + global $sitepress; + if ( 0 === $old_id ) { + $sitepress->set_element_language_details( $rtn_post_id, 'post_apl_design', null, ICL_LANGUAGE_CODE ); + } + } + + // ERROR. + if ( is_wp_error( $rtn_post_id ) ) { + $errors = $rtn_post_id->get_error_messages(); + foreach ( $errors as $error ) { + echo $error; + } + } + } + + /** + * Update Design post data + * + * Inserts APL Design's post args to the database to update a WP_Post. + * + * @ignore + * @since 0.4.0 + * @access private + * + * @param type $args Post arg array for creating Post objects. + */ + private function update_design_post( $args = array() ) { + $defaults = $this->default_postarr(); + $args = wp_parse_args( $args, $defaults ); + + global $wp_rewrite; + if ( is_null( $wp_rewrite ) ) { + $wp_rewrite = new WP_Rewrite(); + } + + remove_all_actions( 'save_post_apl_design', 10 ); + add_action( 'save_post_apl_design', array( &$this, 'hook_action_save_post_apl_design' ), 10, 3 ); + $rtn_post_id = wp_update_post( $args ); + + // ERROR. + if ( is_wp_error( $rtn_post_id ) ) { + $errors = $rtn_post_id->get_error_messages(); + foreach ( $errors as $error ) { + echo $error; + } + } + } + + /** + * Default Post Arg Array + * + * Sets the default Post Argument Array for WP_Post objects. + * + * @ignore + * @since 0.4.0 + * @access private + * + * @see wp_insert_post & wp_update_post for param $postarr. + * @link https://developer.wordpress.org/reference/functions/wp_insert_post/ + * @link https://developer.wordpress.org/reference/functions/wp_update_post/ + * + * @return array Variable for postarr param. + */ + private function default_postarr() { + return array( + //'ID' => 0, + //'post_author' => $user_id, + //'post_date' => '', Default: is current time. + //'post_date_gmt' => '', Default: is $post_date. + //'post_content' => '', + //'post_content_filtered' => '', + 'post_title' => '', + 'post_name' => '', + //'post_excerpt' => '', + //'post_status' => 'draft', + 'post_type' => 'apl_design', + //'comment_status' => '', + //'ping_status' => '', + //'post_password' => '', + //'to_ping' => '', + //'pinged' => '', + //'post_parent' => 0, + //'menu_order' => 0, + //'guid' => '', + //'import_id' => 0, + //'context' => '', + ); + } + + /** + * Hook for Saving Design Post Meta + * + * WP hook for saving meta data in APL Design post type. This fires when + * either insert or update post has been used. + * + * @since 0.4.0 + * + * @param int $post_id Post ID that is past by WP when saving post. + */ + public function hook_action_save_post_apl_design( $post_id, $post_obj, $update ) { + $this->id = $post_id; + $this->title = $post_obj->post_title; + $this->slug = $post_obj->post_name; + + $old_before = get_post_meta( $this->id, 'apl_before', true ); + $old_content = get_post_meta( $this->id, 'apl_content', true ); + $old_after = get_post_meta( $this->id, 'apl_after', true ); + $old_empty = get_post_meta( $this->id, 'apl_empty', true ); + + if ( $old_before !== $this->before ) { + update_post_meta( $this->id, 'apl_before', $this->before ); + } + if ( $old_content !== $this->content ) { + update_post_meta( $this->id, 'apl_content', $this->content ); + } + if ( $old_after !== $this->after ) { + update_post_meta( $this->id, 'apl_after', $this->after ); + } + if ( $old_empty !== $this->empty ) { + update_post_meta( $this->id, 'apl_empty', $this->empty ); + } + + remove_action( 'save_post_apl_design', array( $this, 'hook_action_save_post_apl_design' ) ); + } +} + + + diff --git a/includes/class/class-apl-post-list.php b/includes/class/class-apl-post-list.php new file mode 100644 index 0000000..5e675ef --- /dev/null +++ b/includes/class/class-apl-post-list.php @@ -0,0 +1,618 @@ + 'any' + * --- OR --- + * @type array X => array( 'post_type_1' ), + * // Consolidate in WP_Query with Tax_Query & Dynamic features. + * // Use first post type for Tax_Query + * @type array X => array( 'post_type_2', 'post_type_3' ) + * } + */ + public $post_type = array( 'any' ); + + /** + * Tax Query filter ( Modified ) + * + * Follows the same general Query_Args structure, but carries additional + * variables used with APL. + * + * @since 0.4.0 + * @access public + * @var array $tax_query { + * $post_type = array( + * 'relation' => 'AND' || 'OR', + * [Y1] => array( + * 'taxonomy' => 'tax_1', + * 'field' => 'id', + * 'terms' => array( 103, 115, 206 ), + * 'include_children' => false, + * 'operator' => 'IN' || 'AND' || -'NOT_IN'-, + * + * 'apl_terms_dynamic' => false, + * 'apl_terms_slug => array( 'alpha', 'beta', 'gamma' ), + * ), + * [Y2] => array( + * 'taxonomy' => 'tax_2', + * 'field' => 'id', + * 'terms' => array( 456, 189, 752 ), + * 'include_children' => false, + * 'operator' => 'IN' || 'AND' || -'NOT_IN'-, + * + * 'apl_terms_dynamic' => false, + * 'apl_terms_slug => array( 'alfa', 'bravo', 'charlie' ), + * ), + * ) + * --- OR --- + * $post_type => {}, //ANY + * --- OR --- + * 'any' => array(), //ANY + * } + */ + public $tax_query = array(); + + /** + * Filter by Page Parents + * + * @since 0.1.0 + * @since 0.4.0 - Changed to an array. + * @access public + * @var array $post_parent__in { + * @type array $post_type => array( 1, 23 ) Contain Post/Page IDs. + * } + */ + public $post_parent__in = array(); + + /** + * Dynamic Page Parents + * + * May want to change to apl_ prefix. + * + * @since 0.4.0 + * @access public + * @var array $post_parent_dynamic { + * Desc + * + * @type boolean $post_type => (bool) Active Post Types with dynamic + * Page Parent settings. + * } + */ + public $post_parent_dynamic = array(); + + /** + * Post List Amount + * + * @since 0.1.0 + * @version 0.3.0 - Changed (string) to (int). + * @var int + */ + public $posts_per_page = 5; + + /** + * Offset + * + * @since 0.4.0 + * @var int + */ + public $offset = 0; + + /** + * Order Filter By + * + * @since 0.1.0 + * @since 0.4.0 Changed from $_list_order_by to $order_by. + * Added 'none', and value as default. + * @var string + */ + public $order_by = 'none'; + + /** + * Order Filter Ascending or Descending + * + * @since 0.1.0 + * @since 0.4.0 Changed from $_list_order to $order + * Changed value to 'DESC' as default. + * @var string + */ + public $order = 'DESC'; + + /** + * Filter by Post Status + * + * Note: Empty default as array( 'public', 'publish' ) + * + * @since 0.3.0 + * @version 0.3.b5 - Change from (string) to (array) => (string). + * @var string | array $post_status { + * $type string 'public', 'publish' || 'private', 'pending' + * } + */ + public $post_status = 'none'; + + /** + * Filter by User Permissions + * + * @since 0.3.0 + * @var string 'none' || 'readable' || 'editable' + */ + public $perm = 'none'; + + /** + * Operator for Author ID filter + * + * @since 0.3.0 + * @since 0.4.0 - Changed from $post_author_operator to $author__bool. + * @var string 'none' || 'in' || 'not_in'. + */ + public $author__bool = 'none'; + + /** + * Filter by Author ID + * + * @since 0.3.0 + * @since 0.4.0 - Change from $post_author_ids to $author__in + * @var array $author__in { + * @type int $index => Author_ID + * } + */ + public $author__in = array(); + + /** + * Filter Stickies + * + * @since 0.3.0 + * @var boolean + */ + public $ignore_sticky_posts = true; + + /** + * Filter Posts + * + * @since 0.3.0 + * @var array => int + */ + public $post__not_in = array(); + + /** + * Filter Current Post/Page + * + * @since 0.1.0 + * @version 0.3.0 - changed (string) to (boolean). + * @var boolean + */ + public $pl_exclude_current = true; + + /** + * Filter Duplicates + * + * @since 0.3.0 + * @var boolean + */ + public $pl_exclude_dupes = false; + + /** + * Design for APL Preset Loop + * + * @since 0.4.0 + * @var string + */ + public $pl_apl_design = ''; + + /** + * APL Post List Constructor + * + * Class Constructor. + * + * @since 0.4.0 + * + * @see Function/method/class relied on + * @link URL + * @global type $varname Description. + * @global type $varname Description. + * + * @param string $post_list_name Post List slug. + */ + public function __construct( $post_list_name ) { + //$this->title = $post_list_name; + $this->slug = (string) sanitize_title_with_dashes( $post_list_name ); + $args = array( + 'name' => $this->slug, + ); + $this->get_data( $args ); + + if ( is_admin() ) { + // Save Design Meta Data Hook. + // Only use 'save_post_{post_type}' for saving object as meta data + // after post has been saved, and data has been process via {status}_{post_type}. + add_action( 'save_post_apl_post_list', array( &$this, 'hook_action_save_post_apl_post_list' ), 10, 3 ); + + // Delete Design Hook. + // Import / Export Hook. + } + } + + /** + * Get APL Post List Data + * + * Get Post Data and set as Post List class. + * + * @since 0.4.0 + * + * @see WP_Query Args. + * @link https://gist.github.com/luetkemj/2023628 + * @see get_post_meta(). + * @link https://developer.wordpress.org/reference/functions/get_post_meta/ + * + * @param array $args WP_Query args. + * @return boolean True if data exists. + */ + private function get_data( $args = array() ) { + $defaults = array( + 'post_type' => 'apl_post_list', + //'post__in' => array(), // Need this? + 'post_status' => array( + 'draft', + 'pending', + 'publish', + 'future', + 'private', + 'trash', + ), + 'posts_per_page' => 1, + //'suppress_filters' => true, + ); + $args = wp_parse_args( $args, $defaults ); + + // If there is a design, set object variables to the meta data. + // Else no designs, return false. + $pl_query = new WP_Query( $args ); + if ( 1 > $pl_query->post_count ) { + return false; + } + $post_list = $pl_query->post; + + if ( $post_list->post_name === $args['name'] && ! empty( $args['name'] ) ) { + $this->id = absint( $post_list->ID ); + $this->title = esc_html( $post_list->post_title ); + $this->slug = sanitize_title_with_dashes( $post_list->post_name ); + + $this->post_type = get_post_meta( $this->id, 'apl_post_type', true ) ?: array( 'any' ); + $this->tax_query = get_post_meta( $this->id, 'apl_tax_query', true ) ?: array(); + $this->post_parent__in = get_post_meta( $this->id, 'apl_post_parent__in', true ) ?: array(); + $this->post_parent_dynamic = get_post_meta( $this->id, 'apl_post_parent_dynamic', true ) ?: array(); + + $this->posts_per_page = get_post_meta( $this->id, 'apl_posts_per_page', true ) ?: 5; + $this->offset = get_post_meta( $this->id, 'apl_offset', true ) ?: 0; + $this->order_by = get_post_meta( $this->id, 'apl_order_by', true ) ?: 'none'; + $this->order = get_post_meta( $this->id, 'apl_order', true ) ?: 'DESC'; + $this->author__bool = get_post_meta( $this->id, 'apl_author__bool', true ) ?: 'none'; + $this->author__in = get_post_meta( $this->id, 'apl_author__in', true ) ?: array(); + $this->post_status = get_post_meta( $this->id, 'apl_post_status', true ) ?: 'none'; + $this->perm = get_post_meta( $this->id, 'apl_perm', true ) ?: 'none'; + $this->post__not_in = get_post_meta( $this->id, 'apl_post__not_in', true ) ?: array(); + + $tmp_ignore_sticky_posts = get_post_meta( $this->id, 'apl_ignore_sticky_posts', true ); + $this->ignore_sticky_posts = ( false !== $tmp_ignore_sticky_posts ) ? (bool) $tmp_ignore_sticky_posts : true; + + $tmp_pl_exclude_current = get_post_meta( $this->id, 'apl_pl_exclude_current', true ); + $this->pl_exclude_current = ( false !== $tmp_pl_exclude_current ) ? (bool) $tmp_pl_exclude_current : true; + + $tmp_pl_exclude_dupes = get_post_meta( $this->id, 'apl_pl_exclude_dupes', true ); + $this->pl_exclude_dupes = ( false !== $tmp_pl_exclude_dupes ) ? (bool) $tmp_pl_exclude_dupes : false; + + //$apl_design_slug = apply_filters( 'apl_post_list_get_data_apl_design_slug', $this->slug ); + $this->pl_apl_design = get_post_meta( $this->id, 'apl_pl_apl_design', true ) ?: ''; + + return true; + } else { + return false; + }// End if(). + } + + /** + * Save APL Post List Object + * + * Inserts or updates the Post List post data with $this object. + * + * @since 0.4.0 + * @access public + */ + public function save_post_list() { + if ( empty( $this->slug ) ) { + return; + } + $get_args = array( + 'post__in' => array( $this->id ), + 'post_type' => 'apl_post_list', + ); + $post_lists = new WP_Query( $get_args ); + + $save_postarr = array( + 'ID' => $this->id, + 'post_title' => $this->title, + 'post_name' => $this->slug, + 'post_status' => 'publish', + 'post_type' => 'apl_post_list', + ); + if ( 1 > $post_lists->post_count || 0 === $this->id ) { + $this->insert_post_list_post( $save_postarr ); + } else { + $this->update_post_list_post( $save_postarr ); + } + } + + /** + * Deletes the Post List + * + * @since 0.4.0 + * + * @link https://codex.wordpress.org/Function_Reference/wp_delete_post + */ + public function delete_post_list() { + wp_delete_post( $this->id, true ); + } + + /** + * Insert Post List post data + * + * Inserts APL Post List's post args to the database to create a new WP_Post. + * + * @since 0.4.0 + * @access private + * + * @param array $args Post arg array for creating Post objects. + */ + private function insert_post_list_post( $args = array() ) { + $defaults = $this->default_postarr(); + $args = wp_parse_args( $args, $defaults ); + + global $wp_rewrite; + if ( is_null( $wp_rewrite ) ) { + $wp_rewrite = new WP_Rewrite(); + } + + remove_all_actions( 'save_post_apl_post_list', 10 ); + add_action( 'save_post_apl_post_list', array( &$this, 'hook_action_save_post_apl_post_list' ), 10, 3 ); + $rtn_post_id = wp_insert_post( $args ); + + // ERROR. + if ( is_wp_error( $rtn_post_id ) ) { + $errors = $rtn_post_id->get_error_messages(); + foreach ( $errors as $error ) { + echo $error; + } + } + } + + /** + * Update Post List post data + * + * Inserts APL Post List's post args to the database to update a WP_Post. + * + * @since 0.4.0 + * @access private + * + * @param type $args Post arg array for creating Post objects. + */ + private function update_post_list_post( $args = array() ) { + $defaults = $this->default_postarr(); + $args = wp_parse_args( $args, $defaults ); + + global $wp_rewrite; + if ( is_null( $wp_rewrite ) ) { + $wp_rewrite = new WP_Rewrite(); + } + + remove_all_actions( 'save_post_apl_post_list', 10 ); + add_action( 'save_post_apl_post_list', array( &$this, 'hook_action_save_post_apl_post_list' ), 10, 3 ); + $rtn_post_id = wp_update_post( $args ); + + // ERROR. + if ( is_wp_error( $rtn_post_id ) ) { + $errors = $rtn_post_id->get_error_messages(); + foreach ( $errors as $error ) { + echo $error; + } + } + } + + /** + * Default Post Arg Array + * + * Sets the default Post Argument Array for WP_Post objects. + * + * @since 0.4.0 + * @access private + * + * @see wp_insert_post & wp_update_post for param $postarr. + * @link https://developer.wordpress.org/reference/functions/wp_insert_post/ + * @link https://developer.wordpress.org/reference/functions/wp_update_post/ + * + * @return array Variable for postarr param. + */ + private function default_postarr() { + return array( + //'ID' => 0, + //'post_author' => $user_id, + //'post_date' => '', Default: is current time. + //'post_date_gmt' => '', Default: is $post_date. + //'post_content' => '', + //'post_content_filtered' => '', + 'post_title' => '', + 'post_name' => '', + //'post_excerpt' => '', + 'post_status' => 'draft', + 'post_type' => 'apl_post_list', + //'comment_status' => '', + //'ping_status' => '', + //'post_password' => '', + //'to_ping' => '', + //'pinged' => '', + //'post_parent' => 0, + //'menu_order' => 0, + //'guid' => '', + //'import_id' => 0, + //'context' => '', + ); + } + + /** + * Meta Data Save Post APL Post List + * + * Description. + * + * @since 0.4.0 + * + * @see Function/method/class relied on + * @link https://codex.wordpress.org/Plugin_API/Action_Reference/wp_insert_post + * @global global $_POST Description. + * + * @param int $post_id Post ID. + * @param WP_Post $post_obj Post object. + * @param boolean $update Whether this is an existing post being updated or not. + */ + public function hook_action_save_post_apl_post_list( $post_id, $post_obj, $update ) { + $this->id = $post_id; + $this->title = $post_obj->post_title; + $this->slug = $post_obj->post_name; + + $old_post_type = get_post_meta( $this->id, 'apl_post_type', true ); + $old_tax_query = get_post_meta( $this->id, 'apl_tax_query', true ); + $old_post_parent__in = get_post_meta( $this->id, 'apl_post_parent__in', true ); + $old_post_parent_dynamic = get_post_meta( $this->id, 'apl_post_parent_dynamic', true ); + + $old_posts_per_page = get_post_meta( $this->id, 'apl_posts_per_page', true ); + $old_offset = get_post_meta( $this->id, 'apl_offset', true ); + $old_order_by = get_post_meta( $this->id, 'apl_order_by', true ); + $old_order = get_post_meta( $this->id, 'apl_order', true ); + $old_author__bool = get_post_meta( $this->id, 'apl_author__bool', true ); + $old_author__in = get_post_meta( $this->id, 'apl_author__in', true ); + $old_post_status = get_post_meta( $this->id, 'apl_post_status', true ); + $old_perm = get_post_meta( $this->id, 'apl_perm', true ); + $old_post__not_in = get_post_meta( $this->id, 'apl_post__not_in', true ); + + $old_ignore_sticky_posts = get_post_meta( $this->id, 'apl_ignore_sticky_posts', true ); + $old_ignore_sticky_posts = ( false !== $old_ignore_sticky_posts ) ? (bool) $old_ignore_sticky_posts : null; + + $old_pl_exclude_current = get_post_meta( $this->id, 'apl_pl_exclude_current', true ); + $old_pl_exclude_current = ( false !== $old_pl_exclude_current ) ? (bool) $old_pl_exclude_current : null; + + $old_pl_exclude_dupes = get_post_meta( $this->id, 'apl_pl_exclude_dupes', true ); + $old_pl_exclude_dupes = ( false !== $old_pl_exclude_dupes ) ? (bool) $old_pl_exclude_dupes : null; + + $old_pl_apl_design = get_post_meta( $this->id, 'apl_pl_apl_design', true ); + + // Compare and update if modified. + if ( $this->post_type !== $old_post_type ) { + update_post_meta( $this->id, 'apl_post_type', $this->post_type ); + } + if ( $this->tax_query !== $old_tax_query ) { + update_post_meta( $this->id, 'apl_tax_query', $this->tax_query ); + } + if ( $this->post_parent__in !== $old_post_parent__in ) { + update_post_meta( $this->id, 'apl_post_parent__in', $this->post_parent__in ); + } + if ( $this->post_parent_dynamic !== $old_post_parent_dynamic ) { + update_post_meta( $this->id, 'apl_post_parent_dynamic', $this->post_parent_dynamic ); + } + if ( $this->posts_per_page !== $old_posts_per_page ) { + update_post_meta( $this->id, 'apl_posts_per_page', $this->posts_per_page ); + } + if ( $this->offset !== $old_offset ) { + update_post_meta( $this->id, 'apl_offset', $this->offset ); + } + if ( $this->order_by !== $old_order_by ) { + update_post_meta( $this->id, 'apl_order_by', $this->order_by ); + } + if ( $this->order !== $old_order ) { + update_post_meta( $this->id, 'apl_order', $this->order ); + } + if ( $this->author__bool !== $old_author__bool ) { + update_post_meta( $this->id, 'apl_author__bool', $this->author__bool ); + } + if ( $this->author__in !== $old_author__in ) { + update_post_meta( $this->id, 'apl_author__in', $this->author__in ); + } + if ( $this->post_status !== $old_post_status ) { + update_post_meta( $this->id, 'apl_post_status', $this->post_status ); + } + if ( $this->perm !== $old_perm ) { + update_post_meta( $this->id, 'apl_perm', $this->perm ); + } + if ( $this->post__not_in !== $old_post__not_in ) { + update_post_meta( $this->id, 'apl_post__not_in', $this->post__not_in ); + } + if ( $this->ignore_sticky_posts !== $old_ignore_sticky_posts ) { + update_post_meta( $this->id, 'apl_ignore_sticky_posts', $this->ignore_sticky_posts ); + } + if ( $this->pl_exclude_current !== $old_pl_exclude_current ) { + update_post_meta( $this->id, 'apl_pl_exclude_current', $this->pl_exclude_current ); + } + if ( $this->pl_exclude_dupes !== $old_pl_exclude_dupes ) { + update_post_meta( $this->id, 'apl_pl_exclude_dupes', $this->pl_exclude_dupes ); + } + if ( $this->pl_apl_design !== $old_pl_apl_design ) { + update_post_meta( $this->id, 'apl_pl_apl_design', $this->pl_apl_design ); + } + + remove_action( 'save_post_apl_post_list', array( &$this, 'hook_action_save_post_apl_post_list' ) ); + } +} diff --git a/includes/class/class-apl-query.php b/includes/class/class-apl-query.php index e2b9a53..f25ad92 100644 --- a/includes/class/class-apl-query.php +++ b/includes/class/class-apl-query.php @@ -4,10 +4,9 @@ * * Query API to WP_Query. * - * @link https://github.com/EkoJr/advanced-post-list/ + * @link https://github.com/Advanced-Post-List/advanced-post-list/ * - * @package WordPress - * @subpackage advanced-post-list.php + * @package advanced-post-list * @since 0.3.0 */ @@ -18,12 +17,13 @@ * concepts that WP doesn't provide. * * @since 0.3.0 - * @since 0.3.b8 Fixed nested code. + * @since 0.3.b8 - Fixed nested code. + * @since 0.4.0 - Changed to use APL_Post_List. */ class APL_Query { /** - * Stores error message when error occurs. + * Stores error message when error occurs * * @todo Possibly Remove, and just use WP_Query API. * @@ -33,363 +33,274 @@ class APL_Query { public $_posts; /** - * Query Args. + * Query_Args Array * * @since 0.3.b7 + * @since 0.4.0 - Changed to snake_case. * @var array */ - public $_query_str_array; + public $query_args_arr = array(); /** - * Constructor for APL Query. + * Constructor for APL Query * * Constructor for APL's Query. Adds post/page dynamics, sets the multi- * dimensional query array, and reduces the amount of query strings to be used. * - * STEP 1: Add page dynamics to the presetObj. - * STEP 2: Set the query strings from the presetObj + * STEP 1: Add current post dynamics to the Post List. + * STEP 2: Set the query strings from the APL_Post_List. * STEP 3: Merge any simular queries to lessen the amount of queries. + * STEP 4: Make any additions/duplications for certain enhancements. * * @since 0.3.0 + * @since 0.4.0 - Change to new object method structure. * - * @param object $preset APL Preset Post List Object. - * @return void + * @param object $apl_post_list APL Preset Post List Object. */ - public function __construct( $preset ) { + public function __construct( $apl_post_list ) { // STEP 1. - $preset = $this->set_presetObj_page_vals( $preset ); - // STEP 2. - $_query_str_array = $this->set_query( $preset ); - // STEP 3. - $this->_query_str_array = $this->query_str_consolidate( $_query_str_array ); - } - - /** - * Set Initial Query. - * - * Sets the initial values for query_str. - * - * STEP 1: Instead of using 'any', use all relevant post types except for - * attachment, revision, and nav_menu_item. - * STEP 2: Set all other variables of query_str to a default value to use. - * STEP 3: Return query string argument array. - * - * @since 0.3.b8 - * @access private - * - * @see Function/method/class relied on - * @link URL - * @global type $varname Description. - * @global type $varname Description. - * - * @return array Query Args. - */ - private function set_query_init() { - // STEP 1. - $post_type_list = get_post_types( '', 'names' ); - $skip_post_types = array( 'attachment', 'revision', 'nav_menu_item' ); - foreach ( $skip_post_types as $value ) { - unset( $post_type_list[ $value ] ); - } - unset( $value ); - unset( $skip_post_types ); + $apl_post_list = $this->add_list_dynamics( $apl_post_list ); // STEP 2. - $arg = array( - 'author' => '', - 'tax_query' => array(), - //'post_parent' => 0, - 'post__in' => array(), - // DO NOT USE IN WP_Query - there will be a manual function at the end. - 'post__not_in' => array(), - 'post_type' => $post_type_list, - 'post_status' => array( - 'publish', - ), - 'nopaging' => false, - 'order' => 'DESC', - 'orderby' => 'date', - 'ignore_sticky_posts' => false, - 'perm' => 'readable', - ); + $this->query_args_arr = $this->set_query_args_arr( $apl_post_list ); // STEP 3. - return $arg; + $this->query_args_arr = $this->query_arg_consolidate( $this->query_args_arr ); + + // STEP 4. + $this->query_args_arr = $this->query_args_accommodate( $this->query_args_arr ); } /** - * Set Query Args. - * - * Used as a repeating function to set multiple query strings. - * - * STEP 1: Clone the param object (REQUIRED). - * STEP 2: Set defaults for query_str. - * STEP 3: Set boolean to determine if the function is repeating. - * STEP 4: If a post types exists, then do **steps 5-7**. - * STEP 5: Go through post parents, if any, and if more than one exists in - * the post type, then repeat this function with 1 less. - * STEP 6: Set query_str's tax_query array variables. - * STEP 7: If more post types exist, then repeat this function. - * STEP 8: If no post types exist, then cycle through any post parents, and - * if more than one exists, repeat this function. - * STEP 9: Add the rest of the base query_str values. - * STEP 10: If more both public and private visibility setting is enabled, - * then duplicate the variable and change one to private. Otherwise - * only change it if private is enabled. - * STEP 11: Return all collected query strings. + * Add Dynamic values to Post List * + * Adds the current global post values for any dynamic settings checked. + * + * @ignore * @since 0.3.b8 + * @since 0.4.0 - Changed to use APL_Post_List object. * @access private * - * @see $query_args - * @link https://gist.github.com/EkoJr/7352549 - * - * @param object $preset APL preset post list objects. - * @return array Multi-dimensional query_str array. + * @param APL_Post_List $apl_post_list + * @return APL_Post_List Modified post list object. */ - private function set_query( $preset ) { - /* - * Found out that relying on the param to be seperate from the call - * stack produces the param to be the same object; acing like a pointer? - */ - // STEP 1. - $preset = clone $preset; - $preset->_postTax = clone $preset->_postTax; + private function add_list_dynamics( $apl_post_list ) { + $post_id = get_the_ID(); + if ( ! $post_id ) { + return $apl_post_list; + } - // Used for collecting and returning an array of $query_str; Multi-Dimensional. - $query_str_arrays = array(); + // EXCLUDE CURRENT POST + if ( $apl_post_list->pl_exclude_current ) { + $apl_post_list->post__not_in[] = $post_id; + } - // STEP 2. - $query_str = $this->set_query_init(); + $current_post_type = get_post_type( $post_id ); + $current_taxonomies = get_post_taxonomies( $post_id ); - /* - * This is used to prevent repeating when the scope of the presetObj has - * already been finished. This is caused by post_parents that have - * post_types/taxonomies and causes the possibility of using set_query - * twice in one instance. - */ - // STEP 3. - $set_query_used = false; + $terms_args = array( + 'orderby' => 'term_id', + 'order' => 'ASC', + 'fields' => 'ids', + ); - // STEP 4. - // POST_TYPES & TAXONOMIES + POST_PARENTS. - // DON'T USE A FOR LOOP for post_types. - $post_type_key = key( (array) $preset->_postTax ); - if ( null !== $post_type_key ) { - $query_str['post_type'] = array(); - - // STEP 5. - // Use this type of FOR loop in order to use the index as a counter. - $parent_count = count( $preset->_postParents ); - for ( $i = 0; $i < $parent_count; $i++ ) { - if ( get_post_type( $preset->_postParents[ $i ] ) === $post_type_key ) { - $query_str['post_parent'] = array_shift( $preset->_postParents ); - - // Cycle through rest of the array to check to see if there - // is another match before deciding to repeat this function. - // Index ($i) needs to cap inside to serve as a break. - $parent_count2 = count( $preset->_postParents ); - for ( $i; $i < $parent_count2; $i++ ) { - if ( get_post_type( $preset->_postParents[ $i ] ) === $post_type_key ) { - $query_str_arrays = array_merge( $query_str_arrays, $this->set_query( $preset ) ); - $set_query_used = true; - $i = count( $preset->_postParents ); + foreach ( $apl_post_list->post_type as $k1_index => $v1_pt_arr ) { + if ( is_array( $v1_pt_arr ) ) { + // POST TYPES. + foreach ( $v1_pt_arr as $k2_index => $v2_pt_slug ) { + // Current Post Type. + // PAGE PARENT. + if ( $current_post_type === $v2_pt_slug ) { + if ( isset( $apl_post_list->post_parent_dynamic[ $v2_pt_slug ] ) ) { + if ( $apl_post_list->post_parent_dynamic[ $v2_pt_slug ] ) { + // Add current Page as Parent and prevent doubles. + $apl_post_list->post_parent__in[ $v2_pt_slug ][] = $post_id; + $apl_post_list->post_parent__in[ $v2_pt_slug ] = array_values( array_unique( $apl_post_list->post_parent__in[ $v2_pt_slug ] ) ); + } + } + } + // TAXONOMIES. + if ( isset( $apl_post_list->tax_query[ $v2_pt_slug ] ) ) { + foreach ( $apl_post_list->tax_query[ $v2_pt_slug ] as $k3_tax_key => &$v3_tax_arr ) { + + if ( 'relation' !== $k3_tax_key ) { + if ( in_array( $v3_tax_arr['taxonomy'], $current_taxonomies, true ) ) { + if ( $v3_tax_arr['apl_terms_dynamic'] ) { + // Add Terms. + $current_taxonomy_terms = wp_get_post_terms( + $post_id, + $v3_tax_arr['taxonomy'], + array( + 'fields' => 'ids', + ) + ); + if ( is_wp_error( $current_taxonomy_terms ) ) { + echo '

        ' . $current_taxonomy_terms->get_error_message() . '

        '; + return; + } + + foreach ( $current_taxonomy_terms as $current_term_id ) { + //$apl_post_list->tax_query[ $v2_pt_slug ]['terms'][] = $current_term_id; + $v3_tax_arr['terms'][] = $current_term_id; + } + + $apl_post_list->tax_query[ $v2_pt_slug ][ $k3_tax_key ]['terms'] = array_values( array_unique( $v3_tax_arr['terms'] ) ); + } + } + } + } + } + }// End Foreach( POST TYPE). + } else { // ANY / ALL. + // TAXONOMIES. + if ( isset( $apl_post_list->tax_query[ $v1_pt_arr ] ) ) { + foreach ( $apl_post_list->tax_query[ $v1_pt_arr ] as $k2_tax_key => &$v2_tax_arr ) { + + if ( 'relation' !== $k2_tax_key ) { + if ( in_array( $v2_tax_arr['taxonomy'], $current_taxonomies, true ) ) { + if ( $v2_tax_arr['apl_terms_dynamic'] ) { + // Add Terms. + $current_taxonomy_terms = wp_get_post_terms( + $post_id, + $v2_tax_arr['taxonomy'], + array( + 'fields' => 'ids', + ) + ); + if ( is_wp_error( $current_taxonomy_terms ) ) { + echo '

        ' . $current_taxonomy_terms->get_error_message() . '

        '; + } + + foreach ( $current_taxonomy_terms as $current_term_id ) { + $v2_tax_arr['terms'][] = $current_term_id; + } + + $apl_post_list->tax_query[ $v1_pt_arr ][ $k2_tax_key ]['terms'] = array_values( array_unique( $v2_tax_arr['terms'] ) ); + } + } } } } - } - - // STEP 6. - $tax_operator = 'OR'; - foreach ( $preset->_postTax->$post_type_key->taxonomies as $taxonomy_slug => $taxonomy_value ) { - if ( true === $taxonomy_value->require_taxonomy ) { - $tax_operator = 'AND'; - } - $term_operator = 'IN'; - if ( true === $taxonomy_value->require_terms ) { - $term_operator = 'AND'; - } - // For the Any/All setting. - if ( in_array( 0, $taxonomy_value->terms ) ) { - // Does this need all terms added or leave empty. - // Note: An empty array with a -1 list amount returns zero posts. - //$taxonomy_value->terms = array(); - $term_args = array( - 'taxonomy' => $taxonomy_slug, - 'fields' => 'ids', - ); - $taxonomy_value->terms = get_terms( $term_args ); - - } - //Set query string's tax_query - $query_str['tax_query'][] = array( - 'taxonomy' => $taxonomy_slug, - 'field' => 'id', - 'terms' => $taxonomy_value->terms, - 'include_children' => false, - 'operator' => $term_operator, - ); - } - $query_str['tax_query']['relation'] = $tax_operator; + // Break Post Type Loop (Just in case). + break; + }// End if(). + }// End foreach(). - $query_str['post_type'] = array( $post_type_key ); - unset( $preset->_postTax->$post_type_key ); - - // STEP 7 - If more post types exist, then repeat this function. - if ( false === count( (array) $preset->_postTax ) > 0 && $set_query_used ) { - $query_str_arrays = array_merge( $query_str_arrays, $this->set_query( $preset ) ); - } - } elseif ( count( $preset->_postParents ) > 0 ) { - // STEP 8. - // POST PARENTS (w/o post_type/Tax). - - // If a Post Parent arg is already set, then repeat this query. This - // is just in case it happens to be set and to prevent overwriting. - $parent_count = count( $preset->_postParents ); - if ( ! empty( $query_str['post_parent'] ) ) { - $query_str_arrays = array_merge( $query_str_arrays, $this->set_query( $preset ) ); - } elseif ( 1 < $parent_count ) { - // Set and continues adding the rest of the page parents, if any. - $query_str['post_parent'] = intval( array_shift( $preset->_postParents ) ); - $query_str['post_type'] = get_post_type( $query_str['post_parent'] ); - $query_str_arrays = array_merge( $query_str_arrays, $this->set_query( $preset ) ); - } else { - $query_str['post_parent'] = intval( array_shift( $preset->_postParents ) ); - $query_str['post_type'] = get_post_type( $query_str['post_parent'] ); - } - }// End if(). - - // STEP 9. - $query_str = array_merge( $query_str, $this->set_query_base_val( $preset ) ); - - // Step 10. - // Otherwise leave alone. - if ( count( (array) $preset->_postVisibility ) === 2 ) { - $query_str_arrays[] = $query_str; - $query_str['post_status'][] = 'private'; - } elseif ( 'private' === $preset->_postVisibility[0] ) { - $query_str['post_status'][] = 'private'; - } - - // STEP 11. - $query_str_arrays[] = $query_str; - - return $query_str_arrays; + return $apl_post_list; } /** - * Summary. + * Set Query Args * - * Sets the base query_str values. - * - * STEP 1: Add author filter settings. - * STEP 2: Add post status filter settings. - * STEP 3: Add order by settings. - * STEP 4: Add user's read perm filter. - * STEP 5: Add or Remove Post IDs. - * STEP 6: Add whether to ignore sticky settings. - * STEP 7: Set List Amount. - * STEP 8: Return query_str's base variable values. + * Sets multiple query_args in query_args_arr. * + * @ignore * @since 0.3.b8 + * @since 0.4.0 - Changed to use APL_Post_List structure. * @access private * - * @param object $preset APL preset post list objects. - * @return array Base values for query_str. + * @see $query_args for WP_Query. + * @link https://gist.github.com/luetkemj/2023628 + * + * @param APL_Post_List $apl_post_list + * @return array Multiple query_args */ - private function set_query_base_val( $preset ) { - // INIT. - $arg = array(); + private function set_query_args_arr( $apl_post_list ) { + $rtn_query_args_arr = array(); + + foreach ( $apl_post_list->post_type as $v1_pt_arr ) { + $tmp_query_args = array(); + + // If there is an array of post types, then loop through and add. + if ( is_array( $v1_pt_arr ) ) { + foreach ( $v1_pt_arr as $v2_pt_slug ) { + $tmp_query_args['post_type'] = array( $v2_pt_slug ); + + //$tmp_query_args['tax_query'] = $apl_post_list->tax_query[ $v2_pt_slug ]; + $tmp_tax_query = $apl_post_list->tax_query[ $v2_pt_slug ]; + + if ( ! empty( $tmp_tax_query ) ) { + $tmp_query_args['tax_query']['relation'] = $tmp_tax_query['relation']; + unset( $tmp_tax_query['relation'] ); + + foreach ( $tmp_tax_query as $tax_arr ) { + // Any / All. + if ( isset( $tax_arr['terms'][0] ) && 0 === $tax_arr['terms'][0] ) { + $terms_args = array( + 'taxonomy' => $tax_arr['taxonomy'], + 'fields' => 'ids', + ); + $tax_arr['terms'] = get_terms( $terms_args ); - /* **** AUTHOR FILTER **** */ - // STEP 1. - if ( 'none' !== $preset->_postAuthorOperator && ! empty( $preset->_postAuthorIDs ) ) { - $author_filter = ''; - $author_operator = ''; - if ( 'exclude' === $preset->_postAuthorOperator ) { - $author_operator = '-'; - } - foreach ( $preset->_postAuthorIDs as $i => $author_id ) { - $author_filter .= $author_operator . $author_id; - $author_count = count( $preset->_postAuthorIDs ) - 1; - // Adds a comma if there is more IDs. - if ( $i < $author_count ) { - $author_filter .= ','; + $tmp_query_args['tax_query'][] = $tax_arr; + } else { + $tmp_query_args['tax_query'][] = $tax_arr; + } + } + } + + // Page Parents. + if ( isset( $apl_post_list->post_parent__in[ $v2_pt_slug ] ) ) { + $tmp_query_args['post_parent__in'] = $apl_post_list->post_parent__in[ $v2_pt_slug ]; + } + } + } else { // ANY. + $tmp_query_args['post_type'] = 'any'; + //$tmp_query_args['tax_query'] = $apl_post_list->tax_query['any']; + + if ( ! empty( $apl_post_list->tax_query[ $v1_pt_arr ] ) ) { + $tmp_tax_query = $apl_post_list->tax_query[ $v1_pt_arr ]; + $tmp_query_args['tax_query']['relation'] = $tmp_tax_query['relation']; + unset( $tmp_tax_query['relation'] ); + + foreach ( $tmp_tax_query as $tax_arr ) { + // Any / All. + if ( 0 === $tax_arr['terms'][0] ) { + $terms_args = array( + 'taxonomy' => $tax_arr['taxonomy'], + 'fields' => 'ids', + ); + $tax_arr['terms'] = get_terms( $terms_args ); + + $tmp_query_args['tax_query'][] = $tax_arr; + } else { + $tmp_query_args['tax_query'][] = $tax_arr; + } + } } - } - $arg['author'] = $author_filter; - } - /* **** POST STATUS **** */ - // STEP 2. - if ( ! empty( $preset->_postStatus ) ) { - $post_status_filter = array(); - foreach ( $preset->_postStatus as $value ) { - $post_status_filter[] = $value; + // Post Parents is empty in 'Any' + //$tmp_query_args['post_parent__in'] = $apl_post_list->post_parent__in['any']; + }// End if(). + + // General Filter. + $tmp_query_args['posts_per_page'] = $apl_post_list->posts_per_page; + $tmp_query_args['offset'] = $apl_post_list->offset; + $tmp_query_args['orderby'] = $apl_post_list->order_by; + $tmp_query_args['order'] = $apl_post_list->order; + // Handle post_status in accommodate method. + $tmp_query_args['post_status'] = $apl_post_list->post_status; + if ( 'none' !== $apl_post_list->perm ) { + $tmp_query_args['perm'] = $apl_post_list->perm; } - $arg['post_status'] = $post_status_filter; - } - - /* **** Order/Sort **** */ - // STEP 3. - if ( ! empty( $preset->_listOrder ) ) { - $arg['order'] = $preset->_listOrder; - } - if ( ! empty( $preset->_listOrderBy ) ) { - $arg['orderby'] = $preset->_listOrderBy; - } - - /* **** Permissions **** */ - // STEP 4. - if ( ! empty( $preset->_userPerm ) ) { - $arg['perm'] = $preset->_userPerm; - } - - /* - * When adding posts, check if there are any invalid post IDs, and then - * filter out any duplicates. This prevents any conflicts that may occur - * with some of the dynamic settings/input. - */ - // STEP 5. - $arg['post__not_in'] = array(); - if ( ! empty( $preset->_listExcludePosts ) ) { - foreach ( $preset->_listExcludePosts as $i => $post_id ) { - if ( 0 !== $post_id && ! empty( $post_id ) ) { - $arg['post__not_in'][] = $post_id; + if ( 'none' !== $apl_post_list->author__bool ) { + if ( 'in' === $apl_post_list->author__in ) { + $tmp_query_args['author__in'] = $apl_post_list->author__in; + } elseif ( 'not_in' === $apl_post_list->author__in ) { + $tmp_query_args['author__not_in'] = $apl_post_list->author__in; } } - $arg['post__not_in'] = array_unique( $arg['post__not_in'] ); - } + $tmp_query_args['ignore_sticky_posts'] = $apl_post_list->ignore_sticky_posts; + $tmp_query_args['post__not_in'] = $apl_post_list->post__not_in; - /* **** Ignore Stickies **** */ - // STEP 6. - // Default WP: False. - if ( ! empty( $preset->_listIgnoreSticky ) ) { - $arg['ignore_sticky_posts'] = $preset->_listIgnoreSticky; - } - - /* **** List Amount **** */ - // STEP 7. - /* - * IF set to -1 (unlimited), preserve the setting. - * - * Otherwise, add List Count/Amount plus the amount of excluded posts - * in order to balance out the total number of posts remaining. - */ - if ( isset( $preset->_listCount ) ) { - if ( -1 === $preset->_listCount ) { - $arg['posts_per_page'] = $preset->_listCount; - } else { - $arg['posts_per_page'] = $preset->_listCount + count( $arg['post__not_in'] ); - } - } + $rtn_query_args_arr[] = $tmp_query_args; + }// End foreach(); - // STEP 8. - return $arg; + return $rtn_query_args_arr; } /** - * Summary. + * Query Args Consolidation * * Merges any simular query strings. * @@ -397,6 +308,7 @@ private function set_query_base_val( $preset ) { * or tax query. * STEP 2: Return (modified) query_str_array. * + * @ignore * @since 0.3.b8 * @access private * @@ -405,60 +317,44 @@ private function set_query_base_val( $preset ) { * @global type $varname Description. * @global type $varname Description. * - * @param array $query_str_array Multi-dimensional query_str array. - * @return $query_str_array Multi-dimensional query_str array. + * @param array $arg_arr Multi-dimensional query_str array. + * @return $query_str_array Multi-dimensional query_str array. */ - private function query_str_consolidate( $query_str_array ) { - // STEP 1. - $query_count = count( $query_str_array ); + private function query_arg_consolidate( $arg_arr ) { + $query_count = count( $arg_arr ); for ( $i = 0; $i < $query_count; $i++ ) { - if ( empty( $query_str_array[ $i ]['post_parent'] ) ) { - $query_count = count( $query_str_array ); + if ( empty( $arg_arr[ $i ]['post_parent'] ) ) { + $query_count = count( $arg_arr ); for ( $j = $i + 1; $j < $query_count; $j++ ) { - // IF there isn't a post_parent that would void a merge and - // IF both query_str does have or not have private post_status. - if ( empty( $query_str_array[ $j ]['post_parent'] ) && - in_array( 'private', $query_str_array[ $i ]['post_status'] ) === in_array( 'private', $query_str_array[ $j ]['post_status'] ) && - $this->tax_query_match( $query_str_array[ $i ]['tax_query'], $query_str_array[ $j ]['tax_query'] ) ) { - - $query_str_array[ $i ] = $this->query_str_merge( $query_str_array[ $i ], $query_str_array[ $j ] ); - unset( $query_str_array[ $j ] ); - $query_str_array = array_values( $query_str_array ); + // IF there is a post_parents; which would conflict. + // IF both query_arg's tax_query match. + if ( isset( $arg_arr[ $i ]['post_parent'] ) && empty( $arg_arr[ $i ]['post_parent'] && + $this->tax_query_match( $arg_arr[ $i ]['tax_query'], $arg_arr[ $j ]['tax_query'] ) ) ) { + + $arg_arr[ $i ]['post_type'][] = $arg_arr['post_type'][0]; + + unset( $arg_arr[ $j ] ); + $arg_arr = array_values( $arg_arr ); + + // Set $i back 1 to do next $j properly. $i--; } } } } - // STEP. - return $query_str_array; - } - - /** - * Merge Query Strings. - * - * Merges two query_str arrays. - * - * @since 0.3.b8 - * @access private - * - * @param array $query_str1 Query string values. - * @param array $query_str2 Query string values. - * @return array Query string values. - */ - private function query_str_merge( $query_str1, $query_str2 ) { - $query_str1['post_type'] = array_merge( $query_str1['post_type'], $query_str2['post_type'] ); - return $query_str1; + return $arg_arr; } /** - * Match Tax Query Args. + * Match Tax Query Args * * Checks to see if there is a 100% relation. * * STEP 1: Check and return false if taxomonies do not have 100% relation. * STEP 2: Return true if there is a 100% relation. * + * @ignore * @since 0.3.b8 * @access private * @@ -475,7 +371,7 @@ private function tax_query_match( $tax_query1, $tax_query2 ) { // STEP 1. if ( $tax_query1['relation'] === $tax_query2['relation'] ) { $tax_query_count1 = count( $tax_query1 ) - 1 ; - for ( $i = 0; $i < $tax_query_count; $i++ ) { + for ( $i = 0; $i < $tax_query_count1; $i++ ) { $tax_match_found = false; $tax_query_count2 = count( $tax_query2 ) - 1 ; for ( $j = 0; $j < $tax_query_count2; $j++ ) { @@ -485,7 +381,7 @@ private function tax_query_match( $tax_query1, $tax_query2 ) { $tax_match_found = true; if ( $tax_query1[ $i ]['operator'] === $tax_query2[ $j ]['operator'] ) { foreach ( $tax_query1[ $i ]['terms'] as $key => $value ) { - if ( ! in_array( $value, $tax_query2[ $j ]['terms'] ) ) { + if ( ! in_array( $value, $tax_query2[ $j ]['terms'], true ) ) { return false; } } @@ -506,100 +402,50 @@ private function tax_query_match( $tax_query1, $tax_query2 ) { } /** - * Set Preset Page Values. - * - * Adds the current global post's values if dynamic settings are checked. + * Add/Change Query Args * - * STEP 1: Get the current $post ID. - * STEP 2: If excluding current post/page is checked, then add post_ID. - * STEP 3: If the post parent dynamic/'current page' option is checked. - * Then see if the post is hierarchical and add it to post parents - * array. - * STEP 4: If any include/dynamic taxonomy terms are selected, then add - * the (global) post's values. - * STEP 5: Return (modified) presetObj. + * Modifications for certain enhancements after query array has been consolidated. * - * @since 0.3.b8 - * @access private + * @ignore + * @since 0.4.0 + * @private * - * @see Function/method/class relied on - * @link URL - * @global type $varname Description. - * @global type $varname Description. - * - * @param object $preset APL preset post list object. - * @return object APL's (modified) preset post list object. + * @param type $query_args_arr + * @return string */ - private function set_presetObj_page_vals( $preset ) { - // STEP 1. - $post_ID = get_the_ID(); - - // STEP 2. - if ( true === $preset->_listExcludeCurrent && ! empty( $post_ID ) ) { - $preset->_listExcludePosts[] = $post_ID; - } - - /* ****************************************************************** */ - /* * PAGE PARENTS *************************************************** */ - /* ****************************************************************** */ - // STEP 3. - $post_post_type = get_post_type( $post_ID ); - $post_hierarchical = is_post_type_hierarchical( $post_post_type ); - foreach ( $preset->_postParents as $key => $value ) { - // If dynamic/current post is enabled, zero (0). - if ( 0 === intval( $value ) ) { - // If the post is a valid page parent (hierarchical), then - // replace 0 with page ID. - if ( $post_hierarchical && ! empty( $post_ID ) ) { - // Replace Current Page Parent indicator with the (real) - // page ID. - $preset->_postParents[ $key ] = $post_ID; + private function query_args_accommodate( $query_args_arr ) { + $rtn_query_args_arr = array(); + foreach ( $query_args_arr as $v1_query_args ) { + if ( is_array( $v1_query_args['post_status'] ) ) { + $public = array_search( 'public', $v1_query_args['post_status'], true ); + $private = array_search( 'private', $v1_query_args['post_status'], true ); + + if ( $public && $private ) { + unset( $v1_query_args['post_status'][ $public ] ); + $rtn_query_args_arr[] = $v1_query_args; + unset( $v1_query_args['post_status'][ $private ] ); + $rtn_query_args_arr[] = $v1_query_args; + } elseif ( $public ) { + unset( $v1_query_args['post_status'][ $public ] ); + $rtn_query_args_arr[] = $v1_query_args; } else { - // Otherwise remove the invalid entry (value 0). - unset( $preset->_postParents[ $key ] ); - $preset->_postParents = array_values( $preset->_postParents ); + $rtn_query_args_arr[] = $v1_query_args; } + } elseif ( 'none' === $v1_query_args['post_status'] ) { + // WP Default. + $v1_query_args['post_status'] = array( 'publish' ); + $rtn_query_args_arr[] = $v1_query_args; + } elseif ( 'any' === $v1_query_args['post_status'] ) { + $v1_query_args['post_status'] = 'any'; + $rtn_query_args_arr[] = $v1_query_args; } } - $preset->_postParents = array_values( array_unique( $preset->_postParents ) ); - - /* ****************************************************************** */ - /* * POST TYPE & TAXONOMIES -> TERMS ******************************** */ - /* ****************************************************************** */ - // STEP 4. - $post_taxonomies = get_post_taxonomies( $post_ID ); - $args_post_terms = array( - 'orderby' => 'term_id', - 'order' => 'ASC', - 'fields' => 'ids', - ); - foreach ( $preset->_postTax as $preset_post_type => $preset_pt_value ) { - if ( $post_post_type === $preset_post_type ) { - foreach ( $preset_pt_value->taxonomies as $preset_taxonomy => $preset_tax_value ) { - if ( true === $preset_tax_value->include_terms ) { - foreach ( $post_taxonomies as $post_taxonomy_value ) { - if ( $preset_taxonomy === $post_taxonomy_value && ! empty( $post_ID ) ) { - $post_taxonomy_terms = wp_get_object_terms( - $post_ID, - $post_taxonomy_value, - $args_post_terms - ); - $preset_tax_value->terms = array_merge( $preset_tax_value->terms, (array) $post_taxonomy_terms ); - $preset_tax_value->terms = array_unique( $preset_tax_value->terms ); - } - } - } - } - } - } - - // STEP 5. - return $preset; + return $rtn_query_args_arr; } /** - * APL Query WP. + * APL Query WP * * Queries multiple instances of this function if there is more than one * query_str. @@ -623,7 +469,6 @@ private function set_presetObj_page_vals( $preset ) { public function query_wp( $query_str_array, $repeated = false ) { $post_in_IDs = array(); $post_not_in_IDs = array(); - $final_query_str = array(); /* * Normally a recursive function will have an exit statement setup first, @@ -634,12 +479,10 @@ public function query_wp( $query_str_array, $repeated = false ) { // STEP 1. if ( true === $repeated ) { // STEP. - // Copy the first Query String Array, and delete it, then shift - // any additional arrays. + // Shift the args when repeating this method / function. + // If more args exist, then repeat this function. + // Merge returned post ids for pre-final query. $query_str = array_shift( $query_str_array ); - - // If more Query Strings Arrays exist, then repeat this function. - // When returned, merge post ids for pre-final query. if ( ! empty( $query_str_array ) ) { $post_in_IDs = array_merge( $this->query_wp( $query_str_array, true ), $post_in_IDs ); } @@ -648,11 +491,13 @@ public function query_wp( $query_str_array, $repeated = false ) { // Since post__in and post__not_in don't mix at all. The 2 variables // are stored seperately. // TODO Create function for Post Include/Exclude. - if ( ! empty( $query_str['post__not_in'] ) ) { - $post_not_in_IDs = $query_str['post__not_in']; - + if ( ! empty( $query_str['post__not_in'] ) && 0 < $query_str['posts_per_page'] ) { + // Removed at final. + //$post_not_in_IDs = $query_str['post__not_in']; + $query_str['posts_per_page'] += count( $query_str['post__not_in'] ); } unset( $query_str['post__not_in'] ); + if ( ! empty( $query_str['post__in'] ) ) { $post_in_IDs = array_merge( $post_in_IDs, $query_str['post__in'] ); } @@ -662,6 +507,7 @@ public function query_wp( $query_str_array, $repeated = false ) { // If Posts Per Page is set to -1/Unlimited, then set nopaging to true. if ( -1 === $query_str['posts_per_page'] ) { $query_str['nopaging'] = true; + $query_str['offset'] = 0; } // STEP. // Sets the query string to just query IDs. @@ -671,9 +517,12 @@ public function query_wp( $query_str_array, $repeated = false ) { // STEP. // Collect an array of Post IDs. $post_IDs = array(); - foreach ( $Query_Obj->posts as $i => $post_ID ) { - $post_IDs[] = intval( $post_ID ); + if ( ! empty( $Query_Obj->posts ) ) { + foreach ( $Query_Obj->posts as $i => $post_ID ) { + $post_IDs[] = intval( $post_ID ); + } } + $post_IDs = array_merge( $post_IDs, $post_in_IDs ); // STEP. @@ -684,6 +533,7 @@ public function query_wp( $query_str_array, $repeated = false ) { } else { // STEP 2. // Repeated === false + /* * This is the Initial and Final Query. This is used to collect IDs first * with 1 or more query_str (that couldn't be consolidated/merged), and @@ -691,9 +541,8 @@ public function query_wp( $query_str_array, $repeated = false ) { * custom post types that couldn't be queried together, and allows * compatability with posts_in & posts_not_in. */ - // STEP. + $post_in_IDs = array_merge( $this->query_wp( $query_str_array, true ) ); - // STEP. $query_str = array_shift( $query_str_array ); // STEP. @@ -707,24 +556,23 @@ public function query_wp( $query_str_array, $repeated = false ) { } $post_in_IDs = array_merge( $post_in_IDs ); - // STEP. + // STEP - Prevent defaulting when there's no posts. if ( empty( $post_in_IDs ) ) { $post_in_IDs[] = 0; } // STEP. // Set FINAL query_str with post IDs. - $final_query_str['post__in'] = $post_in_IDs; - $final_query_str['post_type'] = 'any'; - $final_query_str['nopaging'] = false; - $final_query_str['order'] = $query_str['order']; - $final_query_str['orderby'] = $query_str['orderby']; - $final_query_str['ignore_sticky_posts'] = $query_str['ignore_sticky_posts']; - - if ( -1 === $query_str['posts_per_page'] ) { - $final_query_str['nopaging'] = true; - } - $final_query_str['posts_per_page'] = $query_str['posts_per_page'] - count( $query_str['post__not_in'] ); + $final_query_str = array( + 'post__in' => $post_in_IDs, + 'post_type' => 'any', + 'posts_per_page' => $query_str['posts_per_page'], + 'offset' => $query_str['offset'], + 'nopaging' => ( -1 === $query_str['posts_per_page'] ) ? true : false, + 'order' => $query_str['order'], + 'orderby' => $query_str['orderby'], + 'ignore_sticky_posts' => $query_str['ignore_sticky_posts'], + ); // Get FINAL Query Object. $final_Query_Obj = new WP_Query( $final_query_str ); @@ -732,47 +580,4 @@ public function query_wp( $query_str_array, $repeated = false ) { return $final_Query_Obj; }// End if(). } - - /** - * Post Not in List. - * - * Removes any posts excluded from the list. - * - * STEP 1: Go though posts. - * STEP 2: If a post matches one of the excluded IDs, then remove the post - * from both post, posts, and post counts in WP_Query class. - * STEP 3: Return WP_Query class. - * - * @since 0.3.b8 - * @access private - * - * @see Function/method/class relied on - * @link URL - * @global type $varname Description. - * @global type $varname Description. - * - * @param object $Query_Obj WP_Query class. - * @param array $post_not_in_IDs Posts to exclude/remove. - * @return object WP_Query class (modified) object. - */ - private function post__not_in( $Query_Obj, $post_not_in_IDs ) { - // STEP 1. - foreach ( $Query_Obj->posts as $i => $post ) { - foreach ( $post_not_in_IDs as $post_not_ID ) { - // STEP 2. - if ( $post->ID === $post_not_ID ) { - unset( $Query_Obj->posts[ $i ] ); - $Query_Obj->post_count -= 1; - $Query_Obj->found_posts -= 1; - if ( $Query_Obj->post->ID === $post_not_ID ) { - $Query_Obj->post = $Query_Obj->posts[ $i + 1 ]; - } - } - } - } - $Query_Obj->posts = array_values( $Query_Obj->posts ); - - // STEP 3. - return $Query_Obj; - } } diff --git a/includes/class/class-apl-shortcodes.php b/includes/class/class-apl-shortcodes.php index 5309db2..fe79d80 100644 --- a/includes/class/class-apl-shortcodes.php +++ b/includes/class/class-apl-shortcodes.php @@ -4,10 +4,9 @@ * * APL Shortcode API: APL_InternalShortcodes class * - * @link https://github.com/EkoJr/advanced-post-list/ + * @link https://github.com/Advanced-Post-List/advanced-post-list/ * - * @package WordPress - * @subpackage advanced-post-list.php + * @package advanced-post-list * @since 0.4.0 */ @@ -45,15 +44,6 @@ class APL_Shortcodes { */ } -/** - * Advanced Post List - Internal Shortcodes - * - * Handles all internal do_shortcodes when preset post lists are called. Each time - * the class object is created, shortcodes are added, replace function used to - * do_shortcodes, and ends by removing shortcodes (currently manual $this->remove). - * - * @since 0.4.0 - */ /** * APL Internal Shortcodes * @@ -65,7 +55,7 @@ class APL_Shortcodes { */ class APL_Internal_Shortcodes { /** - * WP_Post object for holding post details accessed by shortcode functions. + * WP_Post object for holding post details accessed by shortcode functions * * @since 0.4.0 * @access private @@ -74,7 +64,7 @@ class APL_Internal_Shortcodes { private $_post; /** - * Post Index in Post Lists to display a digit. + * Post Index in Post Lists to display a digit * * @since 0.1.0 * @since 0.4.0 - Added to Class Object. @@ -84,7 +74,7 @@ class APL_Internal_Shortcodes { private $_item_count; /** - * APL (Internal) Shortcode Constructor. + * APL (Internal) Shortcode Constructor * * Desc: Loads/Adds all the internal shortcodes to WordPress, and sets the * class _post to default with Global Post. @@ -96,8 +86,6 @@ class APL_Internal_Shortcodes { * @access public * * @global WP_Post $post Used to store in $this->_post. - * - * @return void */ public function __construct() { // STEP 1. @@ -113,7 +101,7 @@ public function __construct() { } /** - * Destruct Shortcode Remove. + * Destruct Shortcode Remove * * Removes the shortcodes added from construction, and unset the class. * Note: Magic Method __destruct wasn't working as intended, and would called @@ -125,8 +113,6 @@ public function __construct() { * * @since 0.4.0 * @access public - * - * @return void */ public function remove() { // STEP 1. @@ -139,10 +125,11 @@ public function remove() { } /** - * List of shortcode tags. + * List of shortcode tags * * Returns an array of shortcode tags used when public shortcodes are used. * + * @ignore * @todo Extension support for additional functionality. * * @since 0.4.0 @@ -201,7 +188,7 @@ private function shortcode_list() { } /** - * Shortcode Replace. + * Shortcode Replace * * Replaces APL's internal shortcodes with RegEx and WP's Shortcode API * with $this->[shortcode]. @@ -243,7 +230,7 @@ public function replace( $preset_content, $wp_post ) { } /** - * ID Shortcode. + * ID Shortcode * * Adds the Post ID. * @@ -270,7 +257,7 @@ public function ID( $atts ) { } /** - * Post Name Shortcode. + * Post Name Shortcode * * Adds the Post Slug (post_name). * @@ -297,7 +284,7 @@ public function post_name( $atts ) { } /** - * Post Slug Shortcode. + * Post Slug Shortcode * * Adds the Post Slug from WP_Post->post_name. * @@ -322,7 +309,7 @@ public function post_slug( $atts ) { } /** - * Post Title Shortcode. + * Post Title Shortcode * * Adds the post/page title. * @@ -374,7 +361,7 @@ public function post_title( $atts ) { } /** - * Post Permalink (URL) Shortcode. + * Post Permalink (URL) Shortcode * * Adds the post/page permalink/URL. * @@ -400,7 +387,7 @@ public function post_permalink( $atts ) { } /** - * Post Guid (WP Default URL) Shortcode. + * Post Guid (WP Default URL) Shortcode * * Adds the post/page Guid. WP's Default URL (.com/?p=396). * @@ -427,7 +414,7 @@ public function guid( $atts ) { } /** - * Post Date Shortcode. + * Post Date Shortcode * * Adds the post/page date. * @@ -464,7 +451,7 @@ public function post_date( $atts ) { } /** - * Post Date GMT Shortcode. + * Post Date GMT Shortcode * * Adds the post/page date. * @@ -501,7 +488,7 @@ public function post_date_gmt( $atts ) { } /** - * Post Date Modified Shortcode. + * Post Date Modified Shortcode * * Adds the post/page modified date. * @@ -538,7 +525,7 @@ public function post_modified( $atts ) { } /** - * Post Date Modified GMT Shortcode. + * Post Date Modified GMT Shortcode * * Adds the post/page modified date GMT. * @@ -575,7 +562,7 @@ public function post_modified_gmt( $atts ) { } /** - * Post Author Shortcode. + * Post Author Shortcode * * Adds the Author/User Data associated with the post. * @@ -662,7 +649,7 @@ public function post_author( $atts ) { } /** - * Post Thumb Shortcode. + * Post Thumb Shortcode * * Adds a Post Thumb/Featured Image URL associated with the post, but * can also grab an image within WP_Post->post_content (extract=on/force). @@ -737,7 +724,7 @@ public function post_thumb( $atts ) { } /** - * Post Content Shortcode. + * Post Content Shortcode * * Adds the Post_Content. * @@ -764,7 +751,7 @@ public function post_content( $atts ) { } /** - * Post Excerpt Shortcode. + * Post Excerpt Shortcode * * Adds the Post Excerpt, or a substring of Post Content. * @@ -835,7 +822,7 @@ public function post_excerpt( $atts ) { } /** - * Post Comment Count Shortcode. + * Post Comment Count Shortcode * * Adds the Post Comment_Count, which displays the amount of comments * per post. @@ -869,7 +856,7 @@ public function comment_count( $atts ) { // TODO ADD Preset Design. Default would use this, but a custom comment shortcode // would have its own design. /** - * Post Comment Shortcode. + * Post Comment Shortcode * * Adds an HTML string to display comments in a set format. * @@ -924,7 +911,7 @@ public function post_comments( $atts ) { if ( '' === $comment->comment_author_url ) { $comment_author = $comment->comment_author; } else { - $comment_author = '' . $comment->comment_author . ""; + $comment_author = '' . $comment->comment_author . ''; } $return_str .= '

        ' . $comment_author . @@ -942,7 +929,7 @@ public function post_comments( $atts ) { } /** - * Page Parent Shortcode. + * Page Parent Shortcode * * Adds Page Parent Title, and optionally with link. * @@ -1012,7 +999,7 @@ public function post_parent( $atts ) { // TODO ADD Array String to filter through like this->post_author. /** - * Post Type Shortcode. + * Post Type Shortcode * * Adds the Post Type (Label) Name associated with the post/page ID. * @@ -1054,7 +1041,7 @@ public function post_type( $atts ) { } /** - * Categories Shortcode. + * Categories Shortcode * * Adds Categories associated with Post/Page. * @@ -1086,9 +1073,9 @@ public function post_categories( $atts ) { $return_str = ''; // STEP 1. - $atts_value['links'] = true; + $links = true; if ( 'false' === strtolower( $atts_value['links'] ) ) { - $atts_value['links'] = false; + $links = false; } // STEP 2. @@ -1098,7 +1085,7 @@ public function post_categories( $atts ) { if ( $post_categories ) { // STEP 3. foreach ( $post_categories as $category ) { - if ( $atts_value['links'] ) { + if ( $links ) { $return_str .= '' . $category->name . ''; } else { $return_str .= $category->name; @@ -1116,7 +1103,7 @@ public function post_categories( $atts ) { } /** - * Tags Shortcode. + * Tags Shortcode * * Adds Tags associated with Post/Page. * @@ -1148,9 +1135,9 @@ public function post_tags( $atts ) { $return_str = ''; // STEP 1. - $atts_value['links'] = true; + $links = true; if ( 'false' === strtolower( $atts_value['links'] ) ) { - $atts_value['links'] = false; + $links = false; } // STEP 2. @@ -1160,7 +1147,7 @@ public function post_tags( $atts ) { if ( $post_tags ) { // STEP 3. foreach ( $post_tags as $tag ) { - if ( $atts_value['links'] ) { + if ( $links ) { $return_str .= '' . $tag->name . ''; } else { $return_str .= $tag->name; @@ -1178,7 +1165,7 @@ public function post_tags( $atts ) { } /** - * Post Terms Shortcode. + * Post Terms Shortcode * * Adds (Custom) Taxonomy Terms associated with Post/Page. Displays both * post and page types, and will display terms from taxonomies that are set @@ -1267,7 +1254,7 @@ public function post_terms( $atts ) { } /** - * Post Meta Shortcode. + * Post Meta Shortcode * * Adds Post MetaData used within posts/pages. Returns empty if nothing * is found. @@ -1309,22 +1296,21 @@ public function post_meta( $atts ) { } /** - * PHP Function Shortcode. + * PHP Function Shortcode * * Adds custom php functions within the environment/instance, and displays * the returned data as a string. * * STEP 1: Check to see if Constant Variable is set, if not, add error then do Step 4. - * STEP 2: Check to see if a function 'name' is given, if empty, add error - * then do Step 4. - * STEP 3: If the function exists, do the function /w 'param'. - * STEP 4: Return string. + * STEP 2: If the function exists, do the function /w 'param'. + * STEP 3: Return string. * * @since 0.3.0 * @since 0.4.0 - Changed to Class function, and uses WP's built-in functions * for setting default attributes & do_shortcode(). * Added Constant APL_ALLOW_PHP to require. * Added Check if function exists. + * Added Else Check for unknown error. * * @param array $atts { * @@ -1345,16 +1331,18 @@ public function php_function( $atts ) { // STEP 1. if ( ! defined( 'KALINS_ALLOW_PHP' ) && ! defined( 'APL_ALLOW_PHP' ) ) { - $return_str .= 'Error: Add define("APL_ALLOW_PHP", true); to wp-config.php for php_function to work.'; + $return_str .= __( 'Error: Add define("APL_ALLOW_PHP", true); to wp-config.php for php_function to work.', 'advanced-post-list' ); } elseif ( true !== APL_ALLOW_PHP || true !== APL_ALLOW_PHP ) { - $return_str .= 'Error: Change define("APL_ALLOW_PHP", true); in ' . - 'wp-config.php for php_function to work.'; - } elseif ( empty( $atts_value['name'] ) && is_admin() ) { - // STEP 2. - $return_str .= 'Error: Name shortcode attribute must have a name. ' . - 'For ex. [php_function name="FUNCTION_NAME"]'; + $return_str .= __( 'Error: Change define("APL_ALLOW_PHP", true); in ', 'advanced-post-list' ) . + __( 'wp-config.php for php_function to work.', 'advanced-post-list' ); + } elseif ( empty( $atts_value['name'] ) ) { + $return_str .= __( 'Error: Name shortcode attribute must have a name. ', 'advanced-post-list' ); + } elseif ( ! function_exists( $atts_value['name'] ) ) { + $return_str .= __( 'Error: Function does not exist. Check name in shortcode or is function name is loaded.', 'advanced-post-list'); + //__( 'For ex. ', 'advanced-post-list' ) . '\[php_function name=\"' . __( 'FUNCTION_NAME', 'advanced-post-list' ) . '\"\]'; + //__( 'For ex. [php_function name="FUNCTION_NAME"]', 'advanced-post-list' ); } elseif ( function_exists( $atts_value['name'] ) ) { - // STEP 3. + // STEP 2. if ( ! empty( $atts_value['param'] ) ) { $return_str .= call_user_func( $atts_value['name'], @@ -1367,14 +1355,23 @@ public function php_function( $atts ) { $this->_post ); } + } else { + $return_str .= __( 'Error: Unknown Error.', 'advanced-post-list'); + $return_str .= '
        '; + $return_str .= __( 'defined APL_ALLOW_PHP: ', 'advanced-post-list' ) . ! defined( 'APL_ALLOW_PHP' ); + $return_str .= '
        '; + $return_str .= __( '$atts name:', 'advanced-post-list' ) . $atts_value['name']; + $return_str .= '
        '; + $return_str .= __( '$atts param:', 'advanced-post-list' ) . $atts_value['param']; + $return_str .= '


        '; } - // STEP 4. + // STEP 3. return $return_str; } /** - * Post List Item Number Shortcode. + * Post List Item Number Shortcode * * Adds a Numeric value to each post; by X amount of increments, and * starting from where it is offset as. @@ -1425,7 +1422,7 @@ public function item_number( $atts ) { } /** - * Final End Post List Shortcode. + * Final End Post List Shortcode * * Determines the End of the Final post to display. * @@ -1455,7 +1452,7 @@ public function final_end( $content ) { } /** - * Kalin's Post PDF Shortcode. + * Kalin's Post PDF Shortcode * * Shortcode for displaying Kalin's Post PDF Plugin. * diff --git a/includes/class/class-apl-updater.php b/includes/class/class-apl-updater.php index db9833b..4a6b159 100644 --- a/includes/class/class-apl-updater.php +++ b/includes/class/class-apl-updater.php @@ -4,10 +4,9 @@ * * Updater object to Advanced Post List * - * @link https://github.com/EkoJr/advanced-post-list/ + * @link https://github.com/Advanced-Post-List/advanced-post-list/ * - * @package WordPress - * @subpackage advanced-post-list.php + * @package advanced-post-list * @since 0.3.0 */ @@ -19,6 +18,16 @@ * @since 0.3.0 */ class APL_Updater { + + /** + * Even Update Occurred + * + * @since 0.4.0 + * @access public + * @var boolean + */ + public $update_occurred = false; + /** * Stores multiple plugin settings within an array. * @@ -29,7 +38,7 @@ class APL_Updater { public $options; /** - * Stores the preset post lists. + * Stores the preset post lists * * @since 0.3.0 * @access private @@ -38,80 +47,157 @@ class APL_Updater { public $preset_db; /** - * Updater Constructor. + * Stores the APL_Post_List Class Data Format + * + * @since 0.4.0 + * @access public + * @var array + */ + + public $apl_post_list_arr = array(); + + /** + * Stores the APL_Design Class Data Format + * + * @since 0.4.0 + * @access public + * @var array + */ + public $apl_design_arr = array(); + + /** + * Updater Constructor * * Constructor for the Updater Class. * * @since 0.3.0 + * @since 0.4.0 - Changed diverse upgrade params to upgrade_items array. * - * @param string $old_version Version number the plugin is currently operating at. - * @param object $preset_db Optional. Current/Old Preset Database Object. Default null. - * @param array $options Optional. The plugin settings stored. - * @return void + * @param string $old_version Version number the plugin is currently operating at. + * $param array $upgrade_items Items needed to be upgraded from the old_version. + * @param string $return_type (Optional) Type of values to return. Default: 'APL' ('APL' || 'OBJECT') + * 'APL' - Returns the APL Classes/Method objects. + * 'OBJECT' - Returns a Standard Class object. + * NOTE: Used for importing, since objects would + * lose the pointers in that given instance. */ - public function __construct( $old_version, $preset_db = null, $options = null ) { - if ( empty( $old_version ) || ( empty( $preset_db ) && empty( $options ) ) ) { - echo 'APL Updater Class Error: empty version and/or empty APL Options & APL Preset Db is being passed to the Updater Class.'; - return; + public function __construct( $old_version, $update_items, $return_type = 'OBJECT' ) { + if ( empty( $old_version ) || empty ( $update_items ) ) { + return new WP_Error( 'apl_updater', __( 'APL Updater Class Error: empty version and/or empty APL Options & APL Preset Db is being passed to the Updater Class.', 'advanced-post-list' ) ); } - // INIT. + // INIT - FILL IN VARIABLES. $this->options = array(); - $this->preset_db = new APL_Preset_Db(); + if ( ! empty( $update_items['options'] ) ) { + $this->options = $update_items['options']; + } + + $this->preset_db = new stdClass(); + if ( ! empty( $update_items['preset_db'] ) ) { + $this->preset_db = $update_items['preset_db']; + } - // FILL IN VARIABLES. - if ( ! empty( $options ) ) { - $this->options = $options; + $this->apl_post_list_arr = array(); + if ( ! empty( $update_items['apl_post_list_arr'] ) ) { + $this->apl_post_list_arr = $update_items['apl_post_list_arr']; } - if ( ! empty( $preset_db ) ) { - $this->preset_db = $preset_db; + + $this->apl_design_arr = array(); + if ( ! empty( $update_items['apl_design_arr'] ) ) { + $this->apl_design_arr = $update_items['apl_design_arr']; } - ////////////////// - //// UPGRADES //// + /* **** UPGRADES **** */ // CONVERT FROM KALIN'S POST LIST TO BASE. if ( 'kalin' === $old_version ) { $this->APL_convert_kalin_to_base(); $old_version = '0.1.0'; } + if ( version_compare( APL_VERSION, $old_version, '>' ) ) { + // UPGRADE FROM BASE TO "0.3.X". + if ( version_compare( '0.3.a1', $old_version, '>' ) ) { + $this->APL_upgrade_to_03a1(); + } + // VERSION 0.3.b5 + if ( version_compare( '0.3.b5', $old_version, '>' ) ) { + $this->APL_upgrade_to_03b5(); + } + // VERSION 0.4.0 + if ( version_compare( '0.4.0', $old_version, '>' ) ) { + if ( ! empty( $this->options ) ) { + $new_options = $this->upgrade_options_03b5_to_040( $this->options ); + $this->options = $new_options; + } + if ( ! empty( $this->preset_db ) ) { + $new_preset_arr = $this->upgrade_preset_db_03b5_to_040( $this->preset_db ); + $this->apl_post_list_arr = $new_preset_arr['apl_post_list']; + $this->apl_design_arr = $new_preset_arr['apl_design']; - // UPGRADE FROM BASE TO "0.3.X". - if ( version_compare( '0.3.a1', $old_version, '>' ) ) { - $this->APL_upgrade_to_03a1(); - } + // Don't delete incase there is a revert. + //delete_option( 'APL_preset_db-default' ); + } + } - if ( version_compare( '0.3.b5', $old_version, '>' ) ) { - $this->APL_upgrade_to_03b5(); + $this->options['version'] = APL_VERSION; + $this->update_occurred = true; } - //////////////////// - //// DOWNGRADES //// + // This is likely to never happen, but just in case...fundamental example. + /* **** DOWNGRADES CONCEPT ( FUTURE REFERENCE ) **** */ // DOWNGRADE FROM 0.3.X TO BASE. /* - if ( version_compare( '0.3.b5', $oldversion, '<' ) ) { - $this->APL_downgrade_from_03b5(); - } - if ( version_compare( '0.3.a1', $oldversion, '<' ) ) { - $this->APL_downgrade_from_03a(); - } + if ( version_compare( '0.3.b5', $oldversion, '<' ) ) { + $this->APL_downgrade_from_03b5(); + } + if ( version_compare( '0.3.a1', $oldversion, '<' ) ) { + $this->APL_downgrade_from_03a(); + } */ - ////// UPDATE VERSION NUMBER ////// - // APL_VERSION - equals the file version located in "advanced-post-list.php". - if ( isset( $this->options['version'] ) && version_compare( APL_VERSION, $old_version, '>' ) ) { - $this->options['version'] = APL_VERSION; + if ( $this->update_occurred ) { + // Fallback option if things go wrong. + update_option( 'apl_backup_update_dev_' . date( 'YmdHi' ), $update_items ); + foreach ( $update_items as $k1_index => $u_item ) { + $option_name1 = 'apl_backup_update_' . sanitize_key( $old_version ) . '_apl_' . $k1_index; + $option_name2 = 'apl_backup_update_' . sanitize_key( $old_version ) . '_' . date( 'YmdHi' ) . '_apl_' . $k1_index; + update_option( $option_name1, $u_item ); + update_option( $option_name2, $u_item ); + } + } + + // Reform Preset Filters to work according to website. Like when importing + // to a different website with the same category names that differ in IDs. + // This corrects those various diviations. + $new_post_list_arr = array(); + foreach ( $this->apl_post_list_arr as $v1_apl_post_list ) { + $new_post_list_arr[] = $this->reform_post_list( $v1_apl_post_list ); } + $this->apl_post_list_arr = $new_post_list_arr; + + // Finalize the APL_Post_List & APL_Design to the proper type/format. + // During Importing, class instances are lost when a static method or + // seperate instance is used. + switch ( $return_type ) { + case 'APL' : + $this->apl_post_list_arr = $this->return_type_apl_post_lists( $this->apl_post_list_arr ); + $this->apl_design_arr = $this->return_type_apl_designs( $this->apl_design_arr ); + break; + case 'OBJECT' : + default : + // Do nothing since everything is already a StdObject. + break; + } + } /** - * Convert Kalin Plugin to APL. + * Convert Kalin Plugin to APL * * Converts data from the previous plugin to APL configured data. * + * @ignore * @since 0.3.0 * @access private - * - * @return void. */ private function APL_convert_kalin_to_base() { $tmp_preset_array = json_decode( $this->preset_db['preset_arr'] ); @@ -119,7 +205,7 @@ private function APL_convert_kalin_to_base() { $this->preset_db = new APL_Preset_Db(); foreach ( $tmp_preset_array as $key => $value ) { - $this->preset_db->_preset_db->$key = new APL_Preset(); + $this->preset_db->_preset_db->$key = new stdClass(); $this->preset_db->_preset_db->$key->reset_to_version( '0.1.0' ); $this->preset_db->_preset_db->$key = $this->APL_convert_preset_kalin_to_base( $value ); @@ -127,10 +213,11 @@ private function APL_convert_kalin_to_base() { } /** - * Convert Kalin's preset to APL's preset. + * Convert Kalin's preset to APL's preset * * Converts individual data from the previous plugin to APL Preset data. * + * @ignore * @since 0.3.0 * @access private * @@ -138,7 +225,9 @@ private function APL_convert_kalin_to_base() { * @return object Base Preset structure to APL. */ private function APL_convert_preset_kalin_to_base( $old_preset ) { - $return_preset = new APL_Preset(); + //$return_preset = new APL_Preset(); + $return_preset = new stdClass(); + $return_preset->reset_to_version( '0.1.0' ); $return_preset->_catsSelected = $old_preset->categories; @@ -169,14 +258,13 @@ private function APL_convert_preset_kalin_to_base( $old_preset ) { } /** - * Upgrade to "0.3.a1". + * Upgrade to "0.3.a1" * * Upgrade APL to 0.3.a1. * + * @ignore * @since 0.3.a1 * @access private - * - * @return void */ private function APL_upgrade_to_03a1() { if ( ! empty( $this->options ) ) { @@ -188,10 +276,11 @@ private function APL_upgrade_to_03a1() { } /** - * Upgrade Options to 0.3.a1. + * Upgrade Options to 0.3.a1 * * Upgrades Options from Base to "0.3.a1". * + * @ignore * @since 0.3.a1 * @access private * @@ -218,10 +307,11 @@ private function APL_upgrade_options_base_to_03a1( $old_options ) { } /** - * Upgrade Preset Database to 0.3.a1. + * Upgrade Preset Database to 0.3.a1 * * Upgrade Preset Database Object to "0.3.a1". * + * @ignore * @since 0.3.a1 * @access private * @@ -237,7 +327,7 @@ private function APL_upgrade_presetDbObj_base_to_03a1( $old_preset ) { foreach ( $old_preset->_preset_db as $key2 => $value2 ) { $return_preset_db->_preset_db->$key2 = $this->APL_upgrade_preset_base_to_03a1( $value2 ); } - } elseif ( ! empty( $old_preset->$key ) ) { + } elseif ( ! empty( $old_preset->$key1 ) ) { $return_preset_db->$key1 = $old_preset->$key1; } } @@ -245,10 +335,11 @@ private function APL_upgrade_presetDbObj_base_to_03a1( $old_preset ) { } /** - * Upgrade preset to 0.3.a1. + * Upgrade preset to 0.3.a1 * * Upgrades Preset object to "0.3.a1". * + * @ignore * @since 0.3.a1 * @access private * @@ -335,10 +426,11 @@ private function APL_upgrade_preset_base_to_03a1( $old_preset ) { } /** - * Upgrade APL to 0.3.b5. + * Upgrade APL to 0.3.b5 * * Upgrades Plugin to "0.3.b5". * + * @ignore * @since 0.3.b5 * @access private * @@ -346,8 +438,6 @@ private function APL_upgrade_preset_base_to_03a1( $old_preset ) { * @link URL * @global type $varname Description. * @global type $varname Description. - * - * @return void */ private function APL_upgrade_to_03b5() { if ( ! empty( $this->options ) ) { @@ -359,10 +449,11 @@ private function APL_upgrade_to_03b5() { } /** - * Upgrade Options from 0.3.a1 to 0.3.b5. + * Upgrade Options from 0.3.a1 to 0.3.b5 * * Upgrades APL's options "0.3.a1" to "0.3.b5". * + * @ignore * @since 0.3.b5 * @access private * @@ -392,10 +483,11 @@ private function APL_upgrade_options_03a1_to_03b5( $old_options ) { } /** - * Upgrade Preset Database from 0.3.a1 to 0.3.b5. + * Upgrade Preset Database from 0.3.a1 to 0.3.b5 * * Upgrades the Preset Database from "0.3.a1" to "0.3.b5". * + * @ignore * @since 0.3.b5 * @access private * @@ -411,7 +503,7 @@ private function APL_upgrade_return_preset_db_03a1_to_03b5( $old_preset ) { foreach ( $old_preset->_preset_db as $key2 => $value2 ) { $return_preset_db->_preset_db->$key2 = $this->APL_upgrade_preset_03a1_to_03b5( $value2 ); } - } elseif ( ! empty( $old_preset->$key ) ) { + } elseif ( ! empty( $old_preset->$key1 ) ) { $return_preset_db->$key1 = $old_preset->$key1; } } @@ -420,10 +512,11 @@ private function APL_upgrade_return_preset_db_03a1_to_03b5( $old_preset ) { } /** - * Upgrade Preset from 0.3.a1 to 0.3.b5. + * Upgrade Preset from 0.3.a1 to 0.3.b5 * * Upgrades Preset from "0.3.a1" to "0.3.b5". * + * @ignore * @since 0.3.b5 * @access private * @@ -489,4 +582,637 @@ private function APL_upgrade_preset_03a1_to_03b5( $old_preset ) { return $return_preset; } + + /** + * Upgrade APL_Options to 0.4.0 + * + * @ignore + * @since 0.4.0 + * @access private + * + * @param array $options + * @return array New APL_Options + */ + private function upgrade_options_03b5_to_040( $options ) { + // SET DEFAULTS MANUALLY. + $rtn_options = $this->options_array(); + + $rtn_options['version'] = APL_VERSION; + + $rtn_options['ignore_post_types'] = isset( $options['ignore_post_types'] ) ? $options['ignore_post_types'] : $rtn_options['ignore_post_types']; + $rtn_options['delete_core_db'] = isset( $options['delete_core_db'] ) ? $options['delete_core_db'] : $rtn_options['delete_core_db']; + $rtn_options['default_empty_enable'] = isset( $options['default_exit'] ) ? $options['default_exit'] : $rtn_options['default_empty_enable']; + $rtn_options['default_empty_output'] = isset( $options['default_exit_msg'] ) ? $options['default_exit_msg'] : $rtn_options['default_empty_output']; + + return $rtn_options; + } + + /** + * Upgrade Preset Database from 0.3.b5 to 0.4.0 + * + * Upgrades the Preset Database from "0.3.b5" to "0.4.0". + * + * @ignore + * @since 0.4.0 + * @access private + * + * @param object $old_preset_db Old Preset Database. + * @return object New Preset structure. + */ + private function upgrade_preset_db_03b5_to_040( $old_preset_db ) { + $rtn_new_preset_arr = array( + 'apl_post_list' => array(), + 'apl_design' => array(), + ); + + foreach ( $old_preset_db as $k1_db_index => $v1_preset_db_var ) { + if ( '_preset_db' === $k1_db_index && ! empty( $v1_preset_db_var ) ) { + foreach ( $v1_preset_db_var as $k2_preset_slug => $old_value ) { + // Replace with stdClass + //$new_post_list = new APL_Post_List( $preset_key ); + $new_post_list = $this->post_list_stdObj(); + + // ADD VALUES. + $new_post_list->slug = sanitize_key( $k2_preset_slug ) ?: $new_post_list->slug; + $new_post_list->title = $new_post_list->slug ?: $new_post_list->title; + + // POST TYPES & TAX_QUERY + // array <= (object). + // array <= (object). + $tmp_post_type_arr = array(); + $tmp_tax_query_arr = array(); + if ( ! empty( $old_value->_postTax ) ) { + // FOR POST TYPES SELECTED + foreach( $old_value->_postTax as $k3_pt_slug => $v3_taxonomies_obj ) { + if ( ! post_type_exists( $k3_pt_slug ) ) { + continue; + } + + // DEFAULTS. + $tmp_tax_query = array(); + $p_relation = 'OR'; + foreach ( $v3_taxonomies_obj->taxonomies as $k4_tax_slug => $v4_tax_obj ) { + if ( ! taxonomy_exists( $k4_tax_slug ) ) { + continue; + } + + // DEFAULTS. + $tmp_tq_item = array( + 'taxonomy' => '', + 'field' => 'id', // Unmodified. + 'terms' => array(), + 'include_children' => false, // Unmodified. + 'operator' => 'IN', + + 'apl_terms_slug' => array(), + 'apl_terms_dynamic' => false, + ); + + // TAXONOMY SLUG. + $tmp_tq_item['taxonomy'] = $k4_tax_slug; + + // REQUIRED TAXONOMY(IES) + if ( $v4_tax_obj->require_taxonomy ) { + $p_relation = 'AND'; + } + + // REQUIRED TERMS. + if ( $v4_tax_obj->require_terms ) { + $tmp_tq_item['operator'] = 'AND'; + } + + // DYNAMIC TERMS [APL] + if ( $v4_tax_obj->include_terms ) { + $tmp_tq_item['apl_terms_dynamic'] = true; + } + + // TERMS. + foreach ( $v4_tax_obj->terms as $k5_ => $v5_term_id ) { + if ( term_exists( $v5_term_id, $k4_tax_slug ) ) { + $p_term_obj = get_term( $v5_term_id, $k4_tax_slug ); + + $tmp_tq_item['terms'][] = $v5_term_id; + $tmp_tq_item['apl_terms_slug'][ $v5_term_id ] = $p_term_obj->slug; + } elseif( 0 === $v5_term_id ) { + $tmp_tq_item['terms'][] = 0; + } + } + + $tmp_tax_query['relation'] = $p_relation; + $tmp_tax_query[] = $tmp_tq_item; + } + + $tmp_post_type_arr[] = array( $k3_pt_slug ); + + // ADD TO FINAL TEMP. + $tmp_tax_query_arr[ $k3_pt_slug ] = array(); + $tmp_tax_query_arr[ $k3_pt_slug ] = $tmp_tax_query; + } + } + + if ( empty( $old_value->_postParents ) && empty( $tmp_post_type_arr ) && empty( $tmp_tax_query_arr ) ) { + // FOR EMPTY TO Post_Type 'Any' + // An empty tax_query is ok. ( ['tax_query']['any'] = array(); ) + $tmp_post_type_arr[] = 'any'; + $tmp_tax_query_arr['any'] = array(); + } + $new_post_list->post_type = $tmp_post_type_arr; + $new_post_list->tax_query = $tmp_tax_query_arr; + + // POST PARENTS & POST DYNAMICS (MAYBE POST TYPE) + // (array)=>(string) + $tmp_post_parent__in_arr = array(); + $tmp_post_parent_dynamic = array(); + + if ( ! empty( $old_value->_postParents ) ) { + $is_dynamic = false; + if ( in_array( '0', $old_value->_postParents ) ) { + $is_dynamic = true; + $dynamic_key = array_search( '0', $old_value->_postParents ); + unset( $old_value->_postParents[ $dynamic_key ] ); + + if ( empty( $old_value->_postParents ) ) { + + $args = array( + 'public' => true, + 'hierarchical' => true + ); + + $post_types = get_post_types( $args, 'names' ); + + foreach ( $post_types as $v3_post_type_slug ) { + if ( 'any' === $tmp_post_type_arr[0] ) { + // Add All Post Types to post_type. + $tmp_post_type_arr[] = $post_types; + + // Set All Page Dynamics to true. + foreach ( $post_types as $v4_post_type_slug ) { + $tmp_post_parent_dynamic[ $v4_post_type_slug ] = true; + } + break; + } + foreach ( $tmp_post_type_arr as $v4_pt_arr ) { + // Add Page Dynamics to already set Post Types + if ( is_array( $v4_pt_arr ) ) { + foreach ( $v4_pt_arr as $v5_pt_slug ) { + $tmp_post_parent_dynamic[ $v5_pt_slug ] = true; + } + } + } + } + } + } else { + // With IDs + foreach ( $old_value->_postParents as $k3_index => $v3_page_id ) { + if ( 0 === intval( $v3_page_id ) ) { + continue; + } + $tmp_page = get_post( $v3_page_id ); + if ( ! empty( $tmp_page ) ) { + if ( empty( $tmp_post_type_arr ) ) { + // IF no post_type set + $tmp_post_type_arr[] = array( $tmp_page->post_type ); + $tmp_post_parent__in_arr[ $tmp_page->post_type ][] = $tmp_page->ID; + } else { + // Process Post Types and Page Parent corralations. + foreach ( $tmp_post_type_arr as $post_type_arr ) { + if ( is_array( $post_type_arr ) ) { + if ( in_array( $tmp_page->post_type, $post_type_arr ) ) { + // If post_type already exists. + $tmp_post_parent__in_arr[ $tmp_page->post_type ][] = $tmp_page->ID; + } else { + // IF no post_type set + $tmp_post_type_arr[] = array( $tmp_page->post_type ); + $tmp_post_parent__in_arr[ $tmp_page->post_type ][] = $tmp_page->ID; + } + } else { + // ANY. + unset( $tmp_post_type_arr ); + $tmp_post_type_arr = array( $tmp_page->post_type ); + $tmp_post_parent__in_arr[ $tmp_page->post_type ][] = $tmp_page->ID; + } + } + } + + // PAGE DYNAMICS. + $tmp_post_parent_dynamic[ $tmp_page->post_type ] = $is_dynamic; + } + } + } + } + $new_post_list->post_type = $tmp_post_type_arr; + $new_post_list->post_parent__in = $tmp_post_parent__in_arr; + $new_post_list->post_parent_dynamic = $tmp_post_parent_dynamic; + + // (int). + $new_post_list->posts_per_page = $old_value->_listCount ?: $new_post_list->posts_per_page; + + // New Option $new_post_list->offset;. + + // (string) + $new_post_list->order_by = $old_value->_listOrderBy ?: $new_post_list->order_by; + // (string) + $new_post_list->order = $old_value->_listOrder ?: $new_post_list->order; + + // (array)=>(string) + // (array)=>(string) + $new_post_list->post_status = $old_value->_postVisibility ?: $new_post_list->post_status; + $new_post_list->post_status = $old_value->_postStatus ? array_merge( $old_value->_postStatus, $new_post_list->post_status ) : $new_post_list->post_status; + + // (string) + $new_post_list->perm = $old_value->_userPerm ?: $new_post_list->perm; + + // (string) + // (array)=>(int) + //$new_post_list->author__bool = $old_value->_postAuthorOperator ?: $new_post_list->author__bool; + if ( isset( $old_value->_postAuthorOperator ) ) { + if ( 'include' === $old_value->_postAuthorOperator ) { + $new_post_list->author__bool = 'in'; + } elseif( 'exclude' === $old_value->_postAuthorOperator ) { + $new_post_list->author__bool = 'not_in'; + } + } + + $new_post_list->author__in = $old_value->_postAuthorIDs ?: $new_post_list->author__in; + + // (boolean) + $new_post_list->ignore_sticky_posts = $old_value->_listIgnoreSticky ?: $new_post_list->ignore_sticky_posts; + + // (array)=>(int) + // String or Array => Int + $new_post_list->post__not_in = $old_value->_listExcludePosts ?: $new_post_list->post__not_in; + + // (boolean) + if ( isset( $old_value->_listExcludeCurrent ) ) { + $new_post_list->pl_exclude_current = $old_value->_listExcludeCurrent; + } elseif ( isset( $old_value->_postExcludeCurrent ) ) { + $new_post_list->pl_exclude_current = $old_value->_postExcludeCurrent; + } + + // (boolean) + $new_post_list->pl_exclude_dupes = $old_value->_listExcludeDuplicates ?: $new_post_list->pl_exclude_dupes; + + /* + * DESIGN OBJECT ( APL_Design() ) + */ + // SET DEFAULTS MANUALLY. + $new_design = $this->design_stdObj(); + + $new_design->title = sanitize_key( $k2_preset_slug ) ?: $new_design->title; + //$new_design->title .= '-design'; + $new_design->slug = $new_design->title; + // Add the design slug to post_list it belongs to. + $new_post_list->pl_apl_design = $new_design->slug; + + $new_design->before = $old_value->_before ?: $new_design->before; + $new_design->content = $old_value->_content ?: $new_design->content; + $new_design->after = $old_value->_after ?: $new_design->after; + $new_design->empty = $old_value->_exit ?: $new_design->empty; + + // Add to Final Temp. + $rtn_new_preset_arr['apl_post_list'][] = $new_post_list; + $rtn_new_preset_arr['apl_design'][] = $new_design; + } + } elseif ( ! empty( $old_preset_db->$k1_db_index ) ) { + // ARE THESE NEEDED ANYMORE? + // Other unmodified APL_Options ( _preset_db_name & _delete ) + //$return_preset_db->$k1_db_index = $old_preset_db->$k1_db_index; + } + } + + return $rtn_new_preset_arr; + } + + private function options_array() { + return array( + 'version' => APL_VERSION, + 'ignore_post_types' => array(), + 'delete_core_db' => false, + 'default_empty_enable' => false, + 'default_empty_output' => '

        ' . __( 'Sorry, but no content is available at this time.', 'advanced-post-list' ) . '

        ', + ); + } + /** + * Post List Object + * + * Sets the object as a stdClass for better handling with various class conflicts. + * + * @ignore + * @since 0.4.0 + * @access private + * + * @return object + */ + private function post_list_stdObj() { + $rtn_post_list = new stdClass(); + + // SET DEFAULTS MANUALLY + $rtn_post_list->id = 0; + $rtn_post_list->slug = ''; + $rtn_post_list->title = ''; + $rtn_post_list->post_type = array( 'any' ); + $rtn_post_list->tax_query = array(); + $rtn_post_list->post_parent__in = array(); + $rtn_post_list->post_parent_dynamic = array(); + $rtn_post_list->posts_per_page = 5; + $rtn_post_list->offset = 0; + $rtn_post_list->order_by = 'none'; + $rtn_post_list->order = 'DESC'; + $rtn_post_list->post_status = 'none'; + $rtn_post_list->perm = 'none'; + $rtn_post_list->author__bool = 'none'; + $rtn_post_list->author__in = array(); + $rtn_post_list->ignore_sticky_posts = true; + $rtn_post_list->post__not_in = array(); + $rtn_post_list->pl_exclude_current = true; + $rtn_post_list->pl_exclude_dupes = false; + $rtn_post_list->pl_apl_design = ''; + + return $rtn_post_list; + } + + /** + * Design Object + * + * Sets the object as a stdClass for better handling with various class conflicts. + * + * @ignore + * @since 0.4.0 + * @access private + * + * @return object + */ + private function design_stdObj() { + $rtn_design = new stdClass(); + + $rtn_design->id = 0; + $rtn_design->title = ''; + $rtn_design->slug = ''; + $rtn_design->before = ''; + $rtn_design->content = ''; + $rtn_design->after = ''; + $rtn_design->empty = ''; + + return $rtn_design; + } + + /** + * Reform to Post List + * + * Used to set the post list to the correct configuration in a given + * website environment. + * + * @ignore + * @since 0.4.0 + * @access private + * + * @param APL_Post_list $apl_post_list + * @return object + */ + private function reform_post_list( $apl_post_list ) { + $new_post_list = $this->post_list_stdObj(); + + $new_post_list->id = $apl_post_list->id ?: $new_post_list->id; + $new_post_list->slug = $apl_post_list->slug ?: $new_post_list->slug; + $new_post_list->title = $apl_post_list->title ?: $new_post_list->title; + + $tmp_post_type = array(); + $tmp_tax_query = array(); + $tmp_post_parent__in = array(); + $tmp_post_parent_dynamic = array(); + foreach ( $apl_post_list->post_type as $k1_ => $v1_post_types ) { + if ( is_array( $v1_post_types ) ) { + + $tmp2_post_type = array(); + foreach ( $v1_post_types as $k2_ => $v2_pt_slug ) { + //$tmp2_post_type[] = $v2_pt_slug; + if ( ! post_type_exists( $v2_pt_slug ) ) { + continue; + } + $tmp2_post_type[] = $v2_pt_slug; + + $p_tax_query = json_decode( json_encode( $apl_post_list->tax_query ), true ); + $tmp_tax_query[ $v2_pt_slug ] = array(); + $tmp_tax_query[ $v2_pt_slug ] = $this->reform_post_list_tax_query( $p_tax_query[ $v2_pt_slug ] ); + + //////////////////////////////////////////////////////////// + + $p_post_parent__in = json_decode( json_encode( $apl_post_list->post_parent__in ), true ); + if ( isset( $p_post_parent__in[ $v2_pt_slug ] ) && ! empty( $p_post_parent__in[ $v2_pt_slug ] ) ) { + $tmp_post_parents = array(); + foreach ( $p_post_parent__in[ $v2_pt_slug ] as $k3_ => $v3_post_id ) { + $args = array( + 'post__in' => array( $v3_post_id ), + 'post_type' => $v2_pt_slug, + 'post_status' => array( + 'draft', + 'pending', + 'publish', + 'future', + 'private', + 'trash', + ), + 'posts_per_page' => 1, + ); + $pl_query = new WP_Query( $args ); + if ( 1 > $pl_query->post_count ) { + continue; + } + $tmp_post_parents[] = $v3_post_id; + } + $tmp_post_parent__in[ $v2_pt_slug ] = $tmp_post_parents; + + $p_post_parent_dynamic = json_decode( json_encode( $apl_post_list->post_parent_dynamic ), true ); + $tmp_post_parent_dynamic[ $v2_pt_slug ] = $p_post_parent_dynamic[ $v2_pt_slug ] ?: false; + } + + } + $tmp_post_type[] = $tmp2_post_type; + + } + // AND if still empty + if ( 'any' === $v1_post_types && empty( $tmp_post_type ) ) { + $v2_pt_slug = 'any'; + $tmp_post_type[] = $v2_pt_slug; + + $p_tax_query = json_decode( json_encode( $apl_post_list->tax_query ), true ); + $tmp_tax_query[ $v2_pt_slug ] = array(); + $tmp_tax_query[ $v2_pt_slug ] = $this->reform_post_list_tax_query( $p_tax_query[ $v2_pt_slug ] ); + } + } + + $new_post_list->post_type = $tmp_post_type; + $new_post_list->tax_query = $tmp_tax_query; + $new_post_list->post_parent__in = $tmp_post_parent__in; + $new_post_list->post_parent_dynamic = $tmp_post_parent_dynamic; + + $new_post_list->posts_per_page = isset( $apl_post_list->posts_per_page ) ? $apl_post_list->posts_per_page : $new_post_list->posts_per_page; + $new_post_list->offset = isset( $apl_post_list->offset ) ? $apl_post_list->offset : $new_post_list->offset; + $new_post_list->order_by = isset( $apl_post_list->order_by ) ? $apl_post_list->order_by : $new_post_list->order_by; + $new_post_list->order = isset( $apl_post_list->order ) ? $apl_post_list->order : $new_post_list->order; + $new_post_list->post_status = isset( $apl_post_list->post_status ) ? $apl_post_list->post_status : $new_post_list->post_status; + $new_post_list->perm = isset( $apl_post_list->perm ) ? $apl_post_list->perm : $new_post_list->perm; + $new_post_list->author__bool = isset( $apl_post_list->author__bool ) ? $apl_post_list->author__bool : $new_post_list->author__bool; + $new_post_list->author__in = isset( $apl_post_list->author__in ) ? $apl_post_list->author__in : $new_post_list->author__in; + $new_post_list->ignore_sticky_posts = isset( $apl_post_list->ignore_sticky_posts ) ? $apl_post_list->ignore_sticky_posts : $new_post_list->ignore_sticky_posts; + $new_post_list->post__not_in = isset( $apl_post_list->post__not_in ) ? $apl_post_list->post__not_in : $new_post_list->post__not_in; + $new_post_list->pl_exclude_current = isset( $apl_post_list->pl_exclude_current ) ? $apl_post_list->pl_exclude_current : $new_post_list->pl_exclude_current; + $new_post_list->pl_exclude_dupes = isset( $apl_post_list->pl_exclude_dupes ) ? $apl_post_list->pl_exclude_dupes : $new_post_list->pl_exclude_dupes; + $new_post_list->pl_apl_design = isset( $apl_post_list->pl_apl_design ) ? $apl_post_list->pl_apl_design : $new_post_list->pl_apl_design; + + return $new_post_list; + } + + /** + * Reform to Tax Query + * + * Used to set the post list's tax_query to the correct configuration in a given + * website environment. + * + * @ignore + * @since 0.4.0 + * @access private + * + * @param type $tax_query + * @return array + */ + private function reform_post_list_tax_query( $tax_query ) { + $rtn_tax_query = array(); + if ( empty( $tax_query ) ) { + return $rtn_tax_query; + } + + $relation = $tax_query['relation'] ?: 'OR'; + unset( $tax_query['relation'] ); + + $tmp2_tax_arr = array(); + foreach ( $tax_query as $k3_ => $v3_tax_arr ) { + if ( ! taxonomy_exists( $v3_tax_arr['taxonomy'] ) ) { + continue; + } + $tmp_tq_item = array( + 'taxonomy' => '', + 'field' => 'id', // Unmodified. + 'terms' => array(), + 'include_children' => false, // Unmodified. + 'operator' => 'IN', + + 'apl_terms_slug' => array(), + 'apl_terms_dynamic' => false, + ); + + $tmp_tq_item['taxonomy'] = $v3_tax_arr['taxonomy']; + $tmp_tq_item['operator'] = $v3_tax_arr['operator'] ?: $tmp_tq_item['operator']; + $tmp_tq_item['apl_terms_dynamic'] = $v3_tax_arr['apl_terms_dynamic'] ?: $tmp_tq_item['apl_terms_dynamic']; + + foreach ( $v3_tax_arr['terms'] as $k4_ => $v4_term_id ) { + if ( 0 >= $v4_term_id ) { + $tmp_tq_item['terms'][] = 0; + continue; + } elseif ( term_exists( $v3_tax_arr['apl_terms_slug'][ $v4_term_id ], $v3_tax_arr['taxonomy'] ) ) { + $p_term_obj = get_term_by( 'slug', $v3_tax_arr['apl_terms_slug'][ $v4_term_id ], $v3_tax_arr['taxonomy'] ); + + $tmp_tq_item['terms'][] = $p_term_obj->term_id; + $tmp_tq_item['apl_terms_slug'][ $p_term_obj->term_id ] = $p_term_obj->slug; + } + } + if ( empty( $tmp_tq_item['terms'] ) ) { + $tmp_tq_item['terms'][] = 0; + } + $tmp2_tax_arr[] = $tmp_tq_item; + } + $rtn_tax_query = $tmp2_tax_arr; + $rtn_tax_query['relation'] = $relation; + + return $rtn_tax_query; + } + + /** + * Object Type for APL Post Lists + * + * This sets the Post Lists as the custom APL_Post_List object. + * + * @ignore + * @since 0.4.0 + * @access private + * + * @param array $apl_post_list_arr Post List array for $this->apl_post_list_arr. + * @return APL_Post_List Custom APL Post List object. + */ + private function return_type_apl_post_lists( $apl_post_list_arr ) { + $rtn_apl_post_list_arr = array(); + + foreach ( $apl_post_list_arr as $apl_post_list ) { + $tmp_apl_post_list = new APL_Post_List( $apl_post_list->slug ); + + $tmp_apl_post_list->title = $apl_post_list->title ?: $tmp_apl_post_list->title; + $tmp_apl_post_list->post_type = $apl_post_list->post_type ? json_decode( json_encode( $apl_post_list->post_type ), true ) : $tmp_apl_post_list->post_type ; + $tmp_apl_post_list->tax_query = $apl_post_list->tax_query ? json_decode( json_encode( $apl_post_list->tax_query ), true ) : $tmp_apl_post_list->tax_query; + $tmp_apl_post_list->post_parent__in = $apl_post_list->post_parent__in ? json_decode( json_encode( $apl_post_list->post_parent__in ), true ) : $tmp_apl_post_list->post_parent__in; + $tmp_apl_post_list->post_parent_dynamic = $apl_post_list->post_parent_dynamic ? json_decode( json_encode( $apl_post_list->post_parent_dynamic ), true ) : $tmp_apl_post_list->post_parent_dynamic; + $tmp_apl_post_list->posts_per_page = $apl_post_list->posts_per_page ?: $tmp_apl_post_list->posts_per_page; + $tmp_apl_post_list->offset = $apl_post_list->offset ?: $tmp_apl_post_list->offset; + $tmp_apl_post_list->order_by = $apl_post_list->order_by ?: $tmp_apl_post_list->order_by; + $tmp_apl_post_list->order = $apl_post_list->order ?: $tmp_apl_post_list->order; + $tmp_apl_post_list->post_status = $apl_post_list->post_status ? json_decode( json_encode( $apl_post_list->post_status ), true ) : $tmp_apl_post_list->post_status; + $tmp_apl_post_list->perm = $apl_post_list->perm ?: $tmp_apl_post_list->perm; + $tmp_apl_post_list->author__bool = $apl_post_list->author__bool ?: $tmp_apl_post_list->author__bool; + $tmp_apl_post_list->author__in = $apl_post_list->author__in ?: $tmp_apl_post_list->author__in; + $tmp_apl_post_list->ignore_sticky_posts = $apl_post_list->ignore_sticky_posts ?: $tmp_apl_post_list->ignore_sticky_posts; + $tmp_apl_post_list->post__not_in = $apl_post_list->post__not_in ?: $tmp_apl_post_list->post__not_in; + $tmp_apl_post_list->pl_exclude_current = $apl_post_list->pl_exclude_current ?: $tmp_apl_post_list->pl_exclude_current; + $tmp_apl_post_list->pl_exclude_dupes = $apl_post_list->pl_exclude_dupes ?: $tmp_apl_post_list->pl_exclude_dupes; + $tmp_apl_post_list->pl_apl_design = $apl_post_list->pl_apl_design ?: $tmp_apl_post_list->pl_apl_design; + + $rtn_apl_post_list_arr[] = $tmp_apl_post_list; + } + + return $rtn_apl_post_list_arr; + } + + /** + * Object Type for APL Designs + * + * This sets the Designs as the custom APL_Design object. + * + * @ignore + * @since 0.4.0 + * @access private + * + * @param array $apl_design_arr Design array for $this->apl_design_arr. + * @return APL_Design Custom APL Design object. + */ + private function return_type_apl_designs( $apl_design_arr ) { + $rtn_apl_design_arr = array(); + + + foreach ( $apl_design_arr as $apl_design ) { + $tmp_apl_design = new APL_Design( $apl_design->slug ); + + $tmp_apl_design->title = $apl_design->title ?: $tmp_apl_design->title; + $tmp_apl_design->before = $apl_design->before ?: $tmp_apl_design->before; + $tmp_apl_design->content = $apl_design->content ?: $tmp_apl_design->content; + $tmp_apl_design->after = $apl_design->after ?: $tmp_apl_design->after; + $tmp_apl_design->empty = $apl_design->empty ?: $tmp_apl_design->empty; + + $rtn_apl_design_arr[] = $tmp_apl_design; + } + + return $rtn_apl_design_arr; + } + +// /** +// * EXAMPLE IF NEED TO SET TO OBJECT. +// */ +// private function return_type_object_post_lists() { +// +// } +// +// /** +// * EXAMPLE IF NEED TO SET TO OBJECT. +// */ +// private function return_type_object_designs() { +// +// } + } diff --git a/includes/class/class-apl-widget.php b/includes/class/class-apl-widget.php index f9eb0be..0fd7e28 100644 --- a/includes/class/class-apl-widget.php +++ b/includes/class/class-apl-widget.php @@ -6,8 +6,7 @@ * * @link https://github.com/EkoJr/advanced-post-list/ * - * @package WordPress - * @subpackage advanced-post-list.php + * @package advanced-post-list * @since 0.3.0 */ @@ -21,6 +20,11 @@ * @since 0.3.0 */ class APL_Widget extends WP_Widget { + /** + * Constructor + * + * @since 0.3.0 + */ public function __construct() { parent::__construct( 'advanced-post-list_default', @@ -29,7 +33,17 @@ public function __construct() { ); } - // This code displays the widget on the screen. + /** + * Widget + * + * This code displays the widget on the screen. + * + * @since 0.3.0 + * + * @global APL_Core $advanced_post_list + * @param array $args + * @param ? $instance + */ public function widget( $args, $instance ) { global $advanced_post_list; extract( $args ); @@ -44,6 +58,13 @@ public function widget( $args, $instance ) { echo $after_widget; } + /** + * Form + * + * @since 0.3.0 + * + * @param type $instance + */ public function form( $instance ) { $preset_db = new APL_Preset_Db( 'default' ); @@ -70,7 +91,17 @@ public function form( $instance ) { echo '

        '; } - // Updates the settings. + /** + * Update + * + * Updates the settings. + * + * @since 0.3.0 + * + * @param type $new_instance + * @param type $old_instance + * @return type + */ public function update( $new_instance, $old_instance ) { return $new_instance; } diff --git a/includes/class/class-apl-preset-db.php b/includes/class/dep-class-apl-preset-db.php similarity index 92% rename from includes/class/class-apl-preset-db.php rename to includes/class/dep-class-apl-preset-db.php index f9799f7..f051d89 100644 --- a/includes/class/class-apl-preset-db.php +++ b/includes/class/dep-class-apl-preset-db.php @@ -9,6 +9,7 @@ * @package WordPress * @subpackage advanced-post-list.php * @since 0.1.0 + * @deprecated 0.4.0 Use Builtin Post Meta */ /** @@ -37,6 +38,25 @@ class APL_Preset_Db { * @var array */ var $_preset_db; + + /** + * Database Array. + * + * @since 0.1.0 + * @since 0.4.0 changed name from $_preset_db to $post_list_db. + * @access public + * @var array + */ + var $post_list_db; + + /** + * Database Array. + * + * @since 0.4.0 + * @access public + * @var array=>string + */ + var $design_db; /** * Delete on Deactivate. @@ -65,8 +85,8 @@ class APL_Preset_Db { * @return void */ public function __construct( $db_name = '' ) { - // INIT. - $this->_preset_db_name = ''; + // DEFAULTS. + $this->_preset_db_name = 'default'; $this->_preset_db = new stdClass(); $this->_delete = 'true'; @@ -91,6 +111,21 @@ public function __construct( $db_name = '' ) { */ public function reset_to_version( $version ) { $this->reset_to_base(); + + foreach ( $this as $key => &$value ) { + $value = null; + unset( $this->$key ); + } + if ( version_compare( '0.4.0', $version, '>' ) ) { + $this->reset_to_base(); + } elseif ( version_compare( '0.3.a1', $version, '<=' ) && version_compare( '0.3.b5', $version, '>' ) ) { + $this->reset_to_03a1(); + } elseif ( version_compare( '0.3.b5', $version, '<=' ) && version_compare( '0.4.0', $version, '>' ) ) { + $this->reset_to_03b5(); + } else { + //if ( version_compare( '0.4.0', $version, '<=' ) && version_compare( 'X.X.X', $version, '>' ) ) + $this->reset_to_040(); + } } /** @@ -108,6 +143,16 @@ private function reset_to_base() { $this->_preset_db = new stdClass(); $this->_delete = 'true'; } + + /** + * + */ + private function reset_to_040() { + $this->_preset_db_name = ''; + $this->post_list_db = array(); + $this->design_db = array(); + $this->_delete = 'true'; + } /** * Load Preset Database. diff --git a/includes/class/class-apl-preset.php b/includes/class/dep-class-apl-preset.php similarity index 78% rename from includes/class/class-apl-preset.php rename to includes/class/dep-class-apl-preset.php index d2f57d4..01e470d 100644 --- a/includes/class/class-apl-preset.php +++ b/includes/class/dep-class-apl-preset.php @@ -9,6 +9,7 @@ * @package WordPress * @subpackage advanced-post-list.php * @since 0.1.0 + * @deprecated 0.4.0 Use APL_Post_List and APL_Design class */ /** @@ -25,7 +26,7 @@ class APL_Preset { * * @since 0.1.0 * @access public - * @var string + * @var array=>string */ public $_postParents; @@ -137,36 +138,12 @@ class APL_Preset { public $_listExcludeCurrent; /** - * Design for Exit/Empty message. - * - * @since 0.3.0 - * @var string - */ - public $_exit; - - /** - * Design for Before Content/Loop. + * Design for APL Preset Loop. * - * @since 0.1.0 + * @since 0.4.0 * @var string */ - public $_before; - - /** - * Design for Content/Loop. - * - * @since 0.1.0 - * @var string - */ - public $_content; - - /** - * Design for Content/Loop. - * - * @since 0.1.0 - * @var string - */ - public $_after; + public $apl_design; /** * Constructor. @@ -179,6 +156,7 @@ class APL_Preset { * User Perms, Author IDs, Author Include/Exclude, * Ignore Sticky Posts, Exclude Duplicates, Exclude Posts. * Design for Empty Message. + * @since 0.4.0 - Changed: before, content, after, & exit to APL_Design Class. * * @return void */ @@ -201,10 +179,22 @@ public function __construct() { $this->_listExcludeDuplicates = (bool) false; $this->_listExcludePosts = array(); - $this->_exit = (string) ''; - $this->_before = (string) ''; - $this->_content = (string) ''; - $this->_after = (string) ''; + $this->apl_design = (string) ''; + // TODO Change to Design slug. Default: preset_name. + } + + /** + * Returns the APL Design slug. + * + * Gets and returns $this->apl_design. + * + * @since 0.4.0 + * + * @return string Returns the slug from variable APL Design. + */ + public function get_apl_design() { + $apl_design = apply_filters( 'apl_design_slug', $this->apl_design, $this ); + return $apl_design; } /** @@ -218,6 +208,7 @@ public function __construct() { * @return void */ public function reset_to_version( $version ) { + // STEP - Unsets $this object's variables. foreach ( $this as $key => &$value ) { $value = null; unset( $this->$key ); @@ -226,11 +217,12 @@ public function reset_to_version( $version ) { $this->reset_to_base(); } elseif ( version_compare( '0.3.a1', $version, '<=' ) && version_compare( '0.3.b5', $version, '>' ) ) { $this->reset_to_03a1(); - } else { - //if (version_compare('0.3.a1', $oldversion, '>')) + } elseif ( version_compare( '0.3.b5', $version, '<=' ) && version_compare( '0.4.0', $version, '>' ) ) { $this->reset_to_03b5(); + } else { + //if ( version_compare( '0.4.0', $version, '<=' ) && version_compare( 'X.X.X', $version, '>' ) ) + $this->reset_to_040(); } - } /** @@ -286,16 +278,11 @@ private function reset_to_base() { private function reset_to_03a1() { $this->_postParent = (array) array(); $this->_postTax = (object) new stdClass(); - $this->_listAmount = (int) 5; - $this->_listOrderBy = (string) ''; $this->_listOrder = (string) ''; - $this->_postStatus = (string) ''; - $this->_postExcludeCurrent = (bool) true; - $this->_before = (string) ''; $this->_content = (string) ''; $this->_after = (string) ''; @@ -313,12 +300,9 @@ private function reset_to_03a1() { private function reset_to_03b5() { $this->_postParents = (array) array(); $this->_postTax = (object) new stdClass(); - $this->_listCount = (int) 5; - $this->_listOrderBy = (string) ''; $this->_listOrder = (string) ''; - $this->_postVisibility = (array) array( 'public' ); $this->_postStatus = (array) array( 'publish' ); $this->_userPerm = (string) 'readable'; @@ -328,10 +312,37 @@ private function reset_to_03b5() { $this->_listExcludeCurrent = (bool) true; $this->_listExcludeDuplicates = (bool) false; $this->_listExcludePosts = array(); - $this->_exit = (string) ''; $this->_before = (string) ''; $this->_content = (string) ''; $this->_after = (string) ''; } + + /** + * Reset to 0.4.0. + * + * Sets the object to version 0.4.0 variables. + * + * @since 0.4.0 + * @access private + * + * @return void + */ + private function reset_to_040() { + $this->_postParents = (array) array(); + $this->_postTax = (object) new stdClass(); + $this->_listCount = (int) 5; + $this->_listOrderBy = (string) ''; + $this->_listOrder = (string) ''; + $this->_postVisibility = (array) array( 'public' ); + $this->_postStatus = (array) array( 'publish' ); + $this->_userPerm = (string) 'readable'; + $this->_postAuthorOperator = (string) 'none'; + $this->_postAuthorIDs = (array) array(); + $this->_listIgnoreSticky = (bool) false; + $this->_listExcludeCurrent = (bool) true; + $this->_listExcludeDuplicates = (bool) false; + $this->_listExcludePosts = array(); + $this->apl_design = ''; + } } diff --git a/includes/functions.php b/includes/functions.php new file mode 100644 index 0000000..a51c323 --- /dev/null +++ b/includes/functions.php @@ -0,0 +1,139 @@ +' . __( 'Sorry, but no content is available at this time.', 'advanced-post-list' ) . '

        '; + + // Step 3. + return $options; +} + +/** + * APL Load Option. + * + * Gets APLOptions from WordPress database and returns it. If there is no data, + * then set to defaults, save, and return options. + * + * @since 0.1.0 + * @since 0.4.0 - Moved to non-class function. + * + * @see Function/method/class relied on + * @link URL + * + * @return object APL option settings. + */ +function apl_options_load() { + $options = get_option( 'apl_options' ); + + if ( false !== $options ) { + return $options; + } else { + $options = apl_options_default(); + apl_options_save( $options ); + return $options; + } +} + +/** + * APL Save Options. + * + * Save APL_Options. + * + * @since 0.1.0 + * @since 0.4.0 - Moved to non-class function. + * + * @see Function/method/class relied on + * @link URL + * + * @param object $options Core option settings. + */ +function apl_options_save( $options ) { + $default_options = apl_options_default(); + $options = wp_parse_args( $options, $default_options ); + + if ( isset( $options ) ) { + update_option( 'apl_options', $options ); + } +} + +/** + * Get Post Types to Display. + * + * Displays a *valid* list of post types that also aren't on the global ignore list. + * + * @since 0.4.0 + * @access private + * + * @see $this->_ignore_post_types. + * + * @return array List of Post Types. + */ +function apl_get_display_post_types() { + $rtn_post_types = array(); + + $options = apl_options_load(); + $ignore_post_types = apl_default_ignore_post_types(); + $ignore_post_types = apply_filters( 'apl_display_post_types_ignore', $ignore_post_types ); + $ignore_post_types = wp_parse_args( $ignore_post_types, $options['ignore_post_types'] ); + + // Get all Post Types. + $post_type_objs = get_post_types( '', 'objects' ); + // Remove ignored Post Types. + foreach ( $ignore_post_types as $value ) { + unset( $post_type_objs[ $value ] ); + } + + foreach ( $post_type_objs as $key => $value ) { + $rtn_post_types[ $key ] = $value->labels->singular_name; + } + + return $rtn_post_types; +} + +/** + * APL's Default Ignore Post Types + * + * @since 0.4.0 + */ +function apl_default_ignore_post_types() { + return array( + 'attachment', + 'revision', + 'nav_menu_item', + 'apl_post_list', + 'apl_design', + ); +} + diff --git a/includes/hooks.php b/includes/hooks.php new file mode 100644 index 0000000..cef6c4e --- /dev/null +++ b/includes/hooks.php @@ -0,0 +1,90 @@ +apl_design'. + * + * @param type $post_list_slug + * @return string Design slug. + */ +function hook_filter_design_slug_for_get_apl_post_list( $post_list_slug ) { + $return_slug = $post_list_slug; + + return $return_slug; +} +//add_filter( 'apl_post_list_get_data_apl_design_slug', 'hook_filter_design_slug_for_get_apl_post_list' ); +//( 'apl_post_list_apl_design_slug', $this->slug ) + +/** + * Used to set the APL_Design slug in 'APL_Post_List->apl_design'. + * + * @param type $post_list_slug + * @return string Design slug. + */ +function hook_filter_design_slug_for_process_apl_post_list( $post_list_slug ) { + $return_slug = $post_list_slug; + + return $return_slug; +} +add_filter( 'apl_post_list_process_apl_design_slug', 'hook_filter_design_slug_for_process_apl_post_list' ); + +/** + * Manually prevents Custom Post Types from being displayed on Add New. + * @param array $ignore_post_types + * @return string + */ +function hook_filter_apl_display_post_types_ignore( $ignore_post_types ) { + $ignore_post_types[] = 'et_pb_layout'; + return $ignore_post_types; +} +add_filter( 'apl_display_post_types_ignore', 'hook_filter_apl_display_post_types_ignore' ); \ No newline at end of file diff --git a/languages/advanced-post-list.pot b/languages/advanced-post-list.pot index cf25213..bad60a4 100644 --- a/languages/advanced-post-list.pot +++ b/languages/advanced-post-list.pot @@ -1,46 +1,869 @@ -# Copyright (C) 2017 Advanced Post List -# This file is distributed under the same license as the Advanced Post List package. +#, fuzzy msgid "" msgstr "" -"Project-Id-Version: Advanced Post List 0.3.5\n" -"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/advanced-post-list\n" -"POT-Creation-Date: 2017-05-24 05:50:57+00:00\n" +"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" +"Project-Id-Version: Advanced Post List\n" +"POT-Creation-Date: 2017-10-29 12:22-0700\n" +"PO-Revision-Date: 2017-10-29 12:21-0700\n" +"Last-Translator: \n" +"Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" +"X-Generator: Poedit 2.0.4\n" +"X-Poedit-Basepath: ..\n" +"X-Poedit-Flags-xgettext: --add-comments=translators:\n" +"X-Poedit-WPHeader: advanced-post-list.php\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;" +"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;" +"_nx_noop:3c,1,2;__ngettext_noop:1,2\n" +"X-Poedit-SearchPath-0: .\n" +"X-Poedit-SearchPathExcluded-0: *.js\n" -#: advanced-post-list.php:42 +#: admin/class-apl-admin.php:62 admin/class-apl-admin.php:74 +msgid "Cheatin' huh?" +msgstr "" + +#: admin/class-apl-admin.php:92 +msgid "You do not have admin capabilities in APL_Admin." +msgstr "" + +#. Plugin Name of the plugin/theme +#: admin/class-apl-admin.php:214 +msgid "Advanced Post List" +msgstr "" + +#: admin/class-apl-admin.php:215 +msgid "Adv. Post List" +msgstr "" + +#: admin/class-apl-admin.php:229 includes/class/class-apl-core.php:216 +msgid "Add New Post List" +msgstr "" + +#: admin/class-apl-admin.php:230 +msgid "Add New" +msgstr "" + +#: admin/class-apl-admin.php:238 +msgid "APL Settings" +msgstr "" + +#: admin/class-apl-admin.php:239 +msgid "Settings" +msgstr "" + +#: admin/class-apl-admin.php:430 +msgid "Select Taxonomy" +msgstr "" + +#: admin/class-apl-admin.php:431 +msgid "# of # taxonomies selected" +msgstr "" + +#: admin/class-apl-admin.php:432 admin/post-list-meta-box-filter.php:578 +#: admin/post-list-meta-box-filter.php:606 +#: admin/post-list-meta-box-filter.php:641 +#: admin/post-list-meta-box-filter.php:664 +msgid "- None -" +msgstr "" + +#: admin/class-apl-admin.php:433 admin/class-apl-admin.php:437 +msgid "# Selected" +msgstr "" + +#: admin/class-apl-admin.php:434 +msgid "Select Status" +msgstr "" + +#: admin/class-apl-admin.php:435 +msgid "Both" +msgstr "" + +#: admin/class-apl-admin.php:436 admin/post-list-meta-box-filter.php:647 +msgid "Published" +msgstr "" + +#: admin/class-apl-admin.php:517 +msgid "Alert" +msgstr "" + +#: admin/class-apl-admin.php:518 +msgid "No Message to Display." +msgstr "" + +#: admin/class-apl-admin.php:519 +msgid "Filename Required" +msgstr "" + +#: admin/class-apl-admin.php:520 +msgid "A filename doesn't exist. \\n Please enter a filename before exporting." +msgstr "" + +#: admin/class-apl-admin.php:521 +msgid "No file(s) selected. Please choose a JSON file to upload." +msgstr "" + +#: admin/class-apl-admin.php:522 +msgid "No File" +msgstr "" + +#: admin/class-apl-admin.php:523 +msgid "Invalid file type. Please choose a JSON file to upload." +msgstr "" + +#: admin/class-apl-admin.php:524 +msgid "Invalid File" +msgstr "" + +#: admin/class-apl-admin.php:525 +msgid "Data successfully imported." +msgstr "" + +#: admin/class-apl-admin.php:526 +msgid "Complete" +msgstr "" + +#: admin/class-apl-admin.php:527 +msgid "Overwrite Presets" +msgstr "" + +#: admin/class-apl-admin.php:528 admin/class-apl-admin.php:534 +msgid "Illegal Characters" +msgstr "" + +#: admin/class-apl-admin.php:529 admin/class-apl-admin.php:535 +msgid "Cannot use (< > : \" / \\ | , ? *)." +msgstr "" + +#: admin/class-apl-admin.php:530 admin/class-apl-admin.php:536 +msgid "Please rename your filename." +msgstr "" + +#: admin/class-apl-admin.php:627 admin/post-list-meta-box-filter.php:581 +msgid "Slug" +msgstr "" + +#: admin/class-apl-admin.php:628 +msgid "Shortcode" +msgstr "" + +#: admin/class-apl-admin.php:704 +msgid "Filter Settings" +msgstr "" + +#: admin/class-apl-admin.php:712 admin/class-apl-admin.php:736 +msgid "Display Settings" +msgstr "" + +#: admin/class-apl-admin.php:756 +msgid "About" +msgstr "" + +#: admin/class-apl-admin.php:767 +msgid "General Settings" +msgstr "" + +#: admin/class-apl-admin.php:775 +msgid "Import / Export" +msgstr "" + +#: admin/class-apl-admin.php:1267 +msgid "Version number is not present in imported file." +msgstr "" + +#: admin/class-apl-admin.php:1419 admin/class-apl-admin.php:1795 +msgid "Any / All" +msgstr "" + +#: admin/post-list-meta-box-design.php:21 +msgid "" +"Used to store any HTML & CSS code that exists before the post/content " +"listings. Useful for div, ul, ol, tables, etc.. As well as storing CSS " +"styling for IDs and Classes." +msgstr "" + +#: admin/post-list-meta-box-design.php:25 +msgid "" +"This where you design how your posts are going to display in the post list. " +"In here you can use HTML, CSS, PHP (requires the PHP shortcode), and the " +"plugin's internal shortcodes. Info can be found at the bottom, or by " +"clicking on the shortcode info found below \"List content\"." +msgstr "" + +#: admin/post-list-meta-box-design.php:29 +msgid "" +"Used for ending any elements that are still open, or to display a final " +"message to the users/visitors." +msgstr "" + +#: admin/post-list-meta-box-design.php:33 +msgid "" +"This container holds the HTML & CSS content and if no posts are found to be " +"listed in the preset. Then the preset post list will display this message. " +"If no Empty Message is found, then the post list will use the Default Empty " +"Message if enabled in the Plugin's Admin Settings. Otherwise, the plugin " +"will display nothing like it was originally set as. Please Note: if you are " +"using the Default Empty Message but you don't want to display anything in a " +"certain preset post list. Then simple create an empty element to fall back " +"on. For example, an empty \"span\" HTML element." +msgstr "" + +#: admin/post-list-meta-box-design.php:51 +msgid "Before list:" +msgstr "" + +#: admin/post-list-meta-box-design.php:60 +msgid "List content:" +msgstr "" + +#: admin/post-list-meta-box-design.php:64 +msgid "List of Shortcodes" +msgstr "" + +#: admin/post-list-meta-box-design.php:74 +msgid "After list:" +msgstr "" + +#: admin/post-list-meta-box-design.php:83 +msgid "Empty Message:" +msgstr "" + +#: admin/post-list-meta-box-design.php:89 +msgid "Enable (Overwrites Default)" +msgstr "" + +#: admin/post-list-meta-box-design.php:102 +msgid "Edit Translation(s) of this Design." +msgstr "" + +#: admin/post-list-meta-box-design.php:105 +msgid "" +"Please save the Post List in order to manage translations of this Design." +msgstr "" + +#: admin/post-list-meta-box-filter.php:24 +msgid "" +"Each (jQuiry UI) accordion contains a separate individual post type. The " +"default post types built into WordPress are Post and Page. Any additional " +"post types are dynamically added in the manner WordPress does. Please Note: " +"Each post/page can have only one post type, which may explain why it has " +"been divided by post types." +msgstr "" + +#: admin/post-list-meta-box-filter.php:26 +msgid "" +"Each taxonomy is generally spit up in two sections, and divided into " +"separate tabs. Hierarchies (categories) are located on the left, and non-" +"hierarchies (tags) are located on the right." +msgstr "" + +#: admin/post-list-meta-box-filter.php:34 +msgid "" +"If selected, and more than one term is checked, then each term must be " +"required within the CPT/taxonomy in order to be displayed in the post list." +msgstr "" + +#: admin/post-list-meta-box-filter.php:36 +msgid "" +"If selected, the post list preset will include any terms the current page/" +"post has within the CTP/taxonomy." +msgstr "" + +#: admin/post-list-meta-box-filter.php:38 +msgid "When checked, any terms will be included within that CPT/taxonomy." +msgstr "" + +#: admin/post-list-meta-box-filter.php:40 +msgid "" +"The numeric value of how many posts you want the post list to display. " +"Negative one (-1) will display all the posts that are available after " +"filtering." +msgstr "" + +#: admin/post-list-meta-box-filter.php:42 +msgid "" +"Choose which page properties to sort from. All of which are built in params " +"used in WP_Query." +msgstr "" + +#: admin/post-list-meta-box-filter.php:56 +msgid "" +"Uses the user permission via. user capabilities to determine what posts to " +"display in the post list to the visitor/user." +msgstr "" + +#: admin/post-list-meta-box-filter.php:62 +msgid "" +"Add post/page IDs, seperated by a comma (,), will prevent those posts from " +"being added to the post list." +msgstr "" + +#: admin/post-list-meta-box-filter.php:64 +msgid "" +"Meant for the built-in post type (Posts) function. When checked, this will " +"prevent sticky posts from always displaying at the top of the post list." +msgstr "" + +#: admin/post-list-meta-box-filter.php:66 +msgid "" +"When checked, the current post being viewed will be excluded from the post " +"list." +msgstr "" + +#: admin/post-list-meta-box-filter.php:68 +msgid "" +"In the \"order that it is received\", each preset post list being viewed " +"will add the post IDs to a global exclude list built into APL. When checked, " +"the preset post list will add the post IDs (listed at the time) to the " +"exclude filter settings in WP_Query. This will remove any posts that have " +"already been displayed to the user by the APL plugin." +msgstr "" + +#: admin/post-list-meta-box-filter.php:121 +msgid "Any / All Terms" +msgstr "" + +#: admin/post-list-meta-box-filter.php:187 +msgid "" +"Adds the Current Page being displayed as a Parent Page, which will then add " +"those child pages." +msgstr "" + +#: admin/post-list-meta-box-filter.php:193 +msgid "Dynamic Parent Page" +msgstr "" + +#: admin/post-list-meta-box-filter.php:200 +#: admin/post-list-meta-box-filter.php:237 +msgid "Add" +msgstr "" + +#: admin/post-list-meta-box-filter.php:201 +#: admin/post-list-meta-box-filter.php:238 +#: admin/post-list-meta-box-filter.php:579 +msgid "ID" +msgstr "" + +#: admin/post-list-meta-box-filter.php:202 +#: admin/post-list-meta-box-filter.php:239 +msgid "Page Title" +msgstr "" + +#: admin/post-list-meta-box-filter.php:344 +msgid "Post Types" +msgstr "" + +#: admin/post-list-meta-box-filter.php:381 +msgid "Taxonomies" +msgstr "" + +#: admin/post-list-meta-box-filter.php:389 +msgid "Parent Pages" +msgstr "" + +#: admin/post-list-meta-box-filter.php:409 +msgid "Req. Taxonomies" +msgstr "" + +#: admin/post-list-meta-box-filter.php:494 +msgid "Require Terms" +msgstr "" + +#: admin/post-list-meta-box-filter.php:501 +msgid "Dynamic Terms" +msgstr "" + +#: admin/post-list-meta-box-filter.php:536 +msgid "List Amount:" +msgstr "" + +#: admin/post-list-meta-box-filter.php:554 +msgid "Offset:" +msgstr "" + +#: admin/post-list-meta-box-filter.php:573 +msgid "Order By:" +msgstr "" + +#: admin/post-list-meta-box-filter.php:580 +msgid "Title" +msgstr "" + +#: admin/post-list-meta-box-filter.php:582 +msgid "Date" +msgstr "" + +#: admin/post-list-meta-box-filter.php:583 +msgid "Modified Date" +msgstr "" + +#: admin/post-list-meta-box-filter.php:584 +msgid "Comments" +msgstr "" + +#: admin/post-list-meta-box-filter.php:585 +msgid "Author" +msgstr "" + +#: admin/post-list-meta-box-filter.php:586 +msgid "Parent" +msgstr "" + +#: admin/post-list-meta-box-filter.php:587 +msgid "Menu Order" +msgstr "" + +#: admin/post-list-meta-box-filter.php:588 +msgid "Random" +msgstr "" + +#: admin/post-list-meta-box-filter.php:591 +msgid "Descending" +msgstr "" + +#: admin/post-list-meta-box-filter.php:592 +msgid "Ascending" +msgstr "" + +#: admin/post-list-meta-box-filter.php:599 +msgid "Authors:" +msgstr "" + +#: admin/post-list-meta-box-filter.php:607 +msgid "From" +msgstr "" + +#: admin/post-list-meta-box-filter.php:608 +msgid "Not From" +msgstr "" + +#: admin/post-list-meta-box-filter.php:636 +msgid "Post Status:" +msgstr "" + +#: admin/post-list-meta-box-filter.php:642 +msgid "Any" +msgstr "" + +#: admin/post-list-meta-box-filter.php:643 +msgid "Public" +msgstr "" + +#: admin/post-list-meta-box-filter.php:644 +msgid "Private (BETA)" +msgstr "" + +#: admin/post-list-meta-box-filter.php:648 +msgid "Pending Review" +msgstr "" + +#: admin/post-list-meta-box-filter.php:649 +msgid "Draft" +msgstr "" + +#: admin/post-list-meta-box-filter.php:650 +msgid "Auto-Draft" +msgstr "" + +#: admin/post-list-meta-box-filter.php:651 +msgid "Scheduled" +msgstr "" + +#: admin/post-list-meta-box-filter.php:652 +msgid "Revisions" +msgstr "" + +#: admin/post-list-meta-box-filter.php:653 +msgid "Trash" +msgstr "" + +#: admin/post-list-meta-box-filter.php:659 +msgid "User Perms:" +msgstr "" + +#: admin/post-list-meta-box-filter.php:665 +msgid "Readable" +msgstr "" + +#: admin/post-list-meta-box-filter.php:666 +msgid "Editable" +msgstr "" + +#: admin/post-list-meta-box-filter.php:675 +msgid "Exclude Post by ID:" +msgstr "" + +#: admin/post-list-meta-box-filter.php:683 +msgid "Enable Sticky Posts:" +msgstr "" + +#: admin/post-list-meta-box-filter.php:689 +msgid "Exclude Current Post:" +msgstr "" + +#: admin/post-list-meta-box-filter.php:695 +msgid "Exclude Duplicate Posts:" +msgstr "" + +#: admin/settings-meta-box-general.php:28 +msgid "Used for ignoring post types when creating/editing a post list." +msgstr "" + +#: admin/settings-meta-box-general.php:30 +msgid "" +"If \"No\" is selected, then the plugin's database data will not be removed " +"when the plugin is deactivated. When re-activated, the plugin data will " +"restored as it was left. Please Note: If the plugin is removed/uninstalled, " +"then the plugin's data will be removed regardless." +msgstr "" + +#: admin/settings-meta-box-general.php:32 +msgid "Enable Default Empty Message: " +msgstr "" + +#: admin/settings-meta-box-general.php:33 +msgid "" +"Used as a default option to use if no posts are found and the Empty Message " +"is empty within the preset post list." +msgstr "" + +#: admin/settings-meta-box-general.php:34 +msgid "Enable Global Exit (boolean): " +msgstr "" + +#: admin/settings-meta-box-general.php:35 +msgid "" +"If enabled (yes), the all presets will fallback on the global/default Empty " +"Message." +msgstr "" + +#: admin/settings-meta-box-general.php:36 +msgid "Empty Message: " +msgstr "" + +#: admin/settings-meta-box-general.php:37 +msgid "" +"Contains the message that will be displayed if no posts are found. HTML and " +"CSS can be used." +msgstr "" + +#: admin/settings-meta-box-general.php:86 +msgid "Save Settings" +msgstr "" + +#: admin/settings-meta-box-import-export.php:14 +msgid "" +"Exports the whole APL preset database/table. Illegal (< > : \" / \\ | , ? *) " +"characters cannot be used as the exported filename." +msgstr "" + +#: admin/settings-meta-box-import-export.php:16 +msgid "" +"Imports data into the database. If there are any pre-existing data, you will " +"be prompted list of overwrite items." +msgstr "" + +#: admin/settings-meta-box-import-export.php:18 +msgid "" +"Designed to restore only the default preset table the plugin initially came " +"with." +msgstr "" + +#: admin/settings-meta-box-import-export.php:23 +msgid "Export Post List Database" +msgstr "" + +#: admin/settings-meta-box-import-export.php:26 +msgid "Filename:" +msgstr "" + +#: admin/settings-meta-box-import-export.php:31 +msgid "Export" +msgstr "" + +#: admin/settings-meta-box-import-export.php:37 +msgid "Import Post List File" +msgstr "" + +#: admin/settings-meta-box-import-export.php:42 +msgid "Upload File:" +msgstr "" + +#: admin/settings-meta-box-import-export.php:48 +msgid "Import" +msgstr "" + +#: admin/settings-meta-box-import-export.php:55 +msgid "Restore Defaults ( WIP )" +msgstr "" + +#: admin/settings-meta-box-import-export.php:58 +msgid "Default Post Lists:" +msgstr "" + +#: admin/settings-meta-box-import-export.php:63 +msgid "" +"Restores the plugin's default preset table only, and will overwrite/add the " +"default Post Lists. This will not delete other Post Lists (as long as the " +"name isn't a default name)." +msgstr "" + +#: admin/settings-meta-box-import-export.php:66 +msgid "" +"Note: This is currently a Work In Progress. The functionality is relatively " +"simple, however, many updates have taken place since then, and many of the " +"defaults are relatively old." +msgstr "" + +#: admin/settings-meta-box-import-export.php:69 +msgid "Restore" +msgstr "" + +#: admin/settings-page.php:19 +msgid "APL - Settings" +msgstr "" + +#: advanced-post-list.php:39 msgid "This plugin requires Wordpress 2.0.2 or higher to operate. " msgstr "" -#: advanced-post-list.php:43 -msgid "Please update!" +#: advanced-post-list.php:40 +msgid "" +"Please update!" +msgstr "" + +#: advanced-post-list.php:41 advanced-post-list.php:45 +msgid "Advanced Post List: Error" msgstr "" -#: advanced-post-list.php:47 +#: advanced-post-list.php:44 msgid "You are attempting to access this plugin directly." msgstr "" -#: includes/class/class-apl-widget.php:27 +#: includes/class/class-apl-core.php:213 +msgid "APL Post Lists" +msgstr "" + +#: includes/class/class-apl-core.php:214 +msgid "Post List" +msgstr "" + +#: includes/class/class-apl-core.php:215 +msgctxt "List" +msgid "Add New" +msgstr "" + +#: includes/class/class-apl-core.php:217 +msgid "Edit Post List" +msgstr "" + +#: includes/class/class-apl-core.php:218 +msgid "New Post List" +msgstr "" + +#: includes/class/class-apl-core.php:219 +msgid "View Post List" +msgstr "" + +#: includes/class/class-apl-core.php:220 +msgid "View Post Lists" +msgstr "" + +#: includes/class/class-apl-core.php:221 +msgid "Search Post Lists" +msgstr "" + +#: includes/class/class-apl-core.php:222 +msgid "No Post Lists found" +msgstr "" + +#: includes/class/class-apl-core.php:223 +msgid "No Post Lists found in Trash" +msgstr "" + +#: includes/class/class-apl-core.php:224 includes/class/class-apl-core.php:283 +msgid ":" +msgstr "" + +#: includes/class/class-apl-core.php:225 +msgid "All Post Lists" +msgstr "" + +#: includes/class/class-apl-core.php:226 +msgid "Post List Archives" +msgstr "" + +#: includes/class/class-apl-core.php:227 +msgid "Post List Attributes" +msgstr "" + +#: includes/class/class-apl-core.php:228 +msgid "Insert into Post List" +msgstr "" + +#: includes/class/class-apl-core.php:229 +msgid "Upload to this Post List" +msgstr "" + +#: includes/class/class-apl-core.php:230 +msgid "APL Post List" +msgstr "" + +#: includes/class/class-apl-core.php:232 +msgid "APL Preset Post Lists." +msgstr "" + +#: includes/class/class-apl-core.php:272 +msgid "APL Designs" +msgstr "" + +#: includes/class/class-apl-core.php:273 +msgid "Design" +msgstr "" + +#: includes/class/class-apl-core.php:274 +msgctxt "design" +msgid "Add New" +msgstr "" + +#: includes/class/class-apl-core.php:275 +msgid "Add New Design" +msgstr "" + +#: includes/class/class-apl-core.php:276 +msgid "Edit Design" +msgstr "" + +#: includes/class/class-apl-core.php:277 +msgid "New Design" +msgstr "" + +#: includes/class/class-apl-core.php:278 +msgid "View Design" +msgstr "" + +#: includes/class/class-apl-core.php:279 +msgid "View Designs" +msgstr "" + +#: includes/class/class-apl-core.php:280 +msgid "Search Designs" +msgstr "" + +#: includes/class/class-apl-core.php:281 +msgid "No Design found" +msgstr "" + +#: includes/class/class-apl-core.php:282 +msgid "No Design found in Trash" +msgstr "" + +#: includes/class/class-apl-core.php:284 +msgid "All Designs" +msgstr "" + +#: includes/class/class-apl-core.php:285 +msgid "Design Archives" +msgstr "" + +#: includes/class/class-apl-core.php:286 +msgid "Design Attributes" +msgstr "" + +#: includes/class/class-apl-core.php:287 +msgid "Insert into Design" +msgstr "" + +#: includes/class/class-apl-core.php:288 +msgid "Upload to this Design" +msgstr "" + +#: includes/class/class-apl-core.php:289 +msgid "APL Design" +msgstr "" + +#: includes/class/class-apl-core.php:291 +msgid "APL Designs for Preset Post Lists." +msgstr "" + +#: includes/class/class-apl-core.php:579 +#: includes/class/class-apl-updater.php:882 includes/functions.php:37 +msgid "Sorry, but no content is available at this time." +msgstr "" + +#: includes/class/class-apl-core.php:681 +msgid "NOTICE: Shortcode name is missing. Ex [post_list name='example']" +msgstr "" + +#: includes/class/class-apl-core.php:737 +msgid "NOTICE: Post list 'name' does not exist or is invalid." +msgstr "" + +#: includes/class/class-apl-shortcodes.php:1334 +msgid "" +"Error: Add define(\"APL_ALLOW_PHP\", true); to wp-config.php for " +"php_function to work." +msgstr "" + +#: includes/class/class-apl-shortcodes.php:1336 +msgid "Error: Change define(\"APL_ALLOW_PHP\", true); in " +msgstr "" + +#: includes/class/class-apl-shortcodes.php:1337 +msgid "wp-config.php for php_function to work." +msgstr "" + +#: includes/class/class-apl-shortcodes.php:1339 +msgid "Error: Name shortcode attribute must have a name. " +msgstr "" + +#: includes/class/class-apl-shortcodes.php:1341 +msgid "" +"Error: Function does not exist. Check name in shortcode or is function name " +"is loaded." +msgstr "" + +#: includes/class/class-apl-shortcodes.php:1359 +msgid "Error: Unknown Error." +msgstr "" + +#: includes/class/class-apl-shortcodes.php:1361 +msgid "defined APL_ALLOW_PHP: " +msgstr "" + +#: includes/class/class-apl-shortcodes.php:1363 +msgid "$atts name:" +msgstr "" + +#: includes/class/class-apl-shortcodes.php:1365 +msgid "$atts param:" +msgstr "" + +#: includes/class/class-apl-updater.php:86 +msgid "" +"APL Updater Class Error: empty version and/or empty APL Options & APL Preset " +"Db is being passed to the Updater Class." +msgstr "" + +#: includes/class/class-apl-widget.php:31 msgid "Advanced Post Lists" msgstr "" -#: includes/class/class-apl-widget.php:28 +#: includes/class/class-apl-widget.php:32 msgid "Display preset post lists" msgstr "" -#. Plugin Name of the plugin/theme -msgid "Advanced Post List" -msgstr "" #. Plugin URI of the plugin/theme msgid "http://wordpress.org/plugins/advanced-post-list/" msgstr "" #. Description of the plugin/theme -msgid "Create highly customizable post lists to display to your users and visitors. Provides a wide array of static settings and dynamic features. Also supports Custom Post Types and Taxonomies." +msgid "" +"Create highly customizable post lists to display to your users and visitors. " +"Provides a wide array of static settings and dynamic features. Also supports " +"Custom Post Types and Taxonomies." msgstr "" #. Author of the plugin/theme diff --git a/languages/en_US.po b/languages/en_US.po new file mode 100644 index 0000000..a27786f --- /dev/null +++ b/languages/en_US.po @@ -0,0 +1,958 @@ +msgid "" +msgstr "" +"Project-Id-Version: Advanced Post List\n" +"POT-Creation-Date: 2017-10-30 16:59-0700\n" +"PO-Revision-Date: 2017-10-30 16:59-0700\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: en_US\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 2.0.4\n" +"X-Poedit-Basepath: ..\n" +"X-Poedit-Flags-xgettext: --add-comments=translators:\n" +"X-Poedit-WPHeader: advanced-post-list.php\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;" +"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;" +"_nx_noop:3c,1,2;__ngettext_noop:1,2\n" +"X-Poedit-SearchPath-0: .\n" +"X-Poedit-SearchPathExcluded-0: *.js\n" + +#: admin/class-apl-admin.php:62 admin/class-apl-admin.php:74 +msgid "Cheatin' huh?" +msgstr "Cheatin' huh?" + +#: admin/class-apl-admin.php:92 +msgid "You do not have admin capabilities in APL_Admin." +msgstr "You do not have admin capabilities in APL_Admin." + +#. Plugin Name of the plugin/theme +#: admin/class-apl-admin.php:214 +msgid "Advanced Post List" +msgstr "Advanced Post List" + +#: admin/class-apl-admin.php:215 +msgid "Adv. Post List" +msgstr "Adv. Post List" + +#: admin/class-apl-admin.php:229 includes/class/class-apl-core.php:216 +msgid "Add New Post List" +msgstr "Add New Post List" + +#: admin/class-apl-admin.php:230 +msgid "Add New" +msgstr "Add New" + +#: admin/class-apl-admin.php:238 +msgid "APL Settings" +msgstr "APL Settings" + +#: admin/class-apl-admin.php:239 +msgid "Settings" +msgstr "Settings" + +#: admin/class-apl-admin.php:430 +msgid "Select Taxonomy" +msgstr "Select Taxonomy" + +#: admin/class-apl-admin.php:431 +msgid "# of # taxonomies selected" +msgstr "# of # taxonomies selected" + +#: admin/class-apl-admin.php:432 admin/post-list-meta-box-filter.php:578 +#: admin/post-list-meta-box-filter.php:606 +#: admin/post-list-meta-box-filter.php:641 +#: admin/post-list-meta-box-filter.php:664 +msgid "- None -" +msgstr "- None -" + +#: admin/class-apl-admin.php:433 admin/class-apl-admin.php:437 +msgid "# Selected" +msgstr "# Selected" + +#: admin/class-apl-admin.php:434 +msgid "Select Status" +msgstr "Select Status" + +#: admin/class-apl-admin.php:435 +msgid "Both" +msgstr "Both" + +#: admin/class-apl-admin.php:436 admin/post-list-meta-box-filter.php:647 +msgid "Published" +msgstr "Published" + +#: admin/class-apl-admin.php:517 +msgid "Alert" +msgstr "Alert" + +#: admin/class-apl-admin.php:518 +msgid "No Message to Display." +msgstr "No Message to Display." + +#: admin/class-apl-admin.php:519 +msgid "Filename Required" +msgstr "Filename Required" + +#: admin/class-apl-admin.php:520 +msgid "A filename doesn't exist. \\n Please enter a filename before exporting." +msgstr "" +"A filename doesn't exist. \\n Please enter a filename before exporting." + +#: admin/class-apl-admin.php:521 +msgid "No file(s) selected. Please choose a JSON file to upload." +msgstr "No file(s) selected. Please choose a JSON file to upload." + +#: admin/class-apl-admin.php:522 +msgid "No File" +msgstr "No File" + +#: admin/class-apl-admin.php:523 +msgid "Invalid file type. Please choose a JSON file to upload." +msgstr "Invalid file type. Please choose a JSON file to upload." + +#: admin/class-apl-admin.php:524 +msgid "Invalid File" +msgstr "Invalid File" + +#: admin/class-apl-admin.php:525 +msgid "Data successfully imported." +msgstr "Data successfully imported." + +#: admin/class-apl-admin.php:526 +msgid "Complete" +msgstr "Complete" + +#: admin/class-apl-admin.php:527 +msgid "Overwrite Presets" +msgstr "Overwrite Presets" + +#: admin/class-apl-admin.php:528 admin/class-apl-admin.php:534 +msgid "Illegal Characters" +msgstr "Illegal Characters" + +#: admin/class-apl-admin.php:529 admin/class-apl-admin.php:535 +msgid "Cannot use (< > : \" / \\ | , ? *)." +msgstr "Cannot use (< > : \" / \\ | , ? *)." + +#: admin/class-apl-admin.php:530 admin/class-apl-admin.php:536 +msgid "Please rename your filename." +msgstr "Please rename your filename." + +#: admin/class-apl-admin.php:627 admin/post-list-meta-box-filter.php:581 +msgid "Slug" +msgstr "Slug" + +#: admin/class-apl-admin.php:628 +msgid "Shortcode" +msgstr "Shortcode" + +#: admin/class-apl-admin.php:704 +msgid "Filter Settings" +msgstr "Filter Settings" + +#: admin/class-apl-admin.php:712 admin/class-apl-admin.php:736 +msgid "Display Settings" +msgstr "Display Settings" + +#: admin/class-apl-admin.php:756 +msgid "About" +msgstr "About" + +#: admin/class-apl-admin.php:767 +msgid "General Settings" +msgstr "General Settings" + +#: admin/class-apl-admin.php:775 +msgid "Import / Export" +msgstr "Import / Export" + +#: admin/class-apl-admin.php:1267 +msgid "Version number is not present in imported file." +msgstr "Version number is not present in imported file." + +#: admin/class-apl-admin.php:1419 admin/class-apl-admin.php:1795 +msgid "Any / All" +msgstr "Any / All" + +#: admin/post-list-meta-box-design.php:21 +msgid "" +"Used to store any HTML & CSS code that exists before the post/content " +"listings. Useful for div, ul, ol, tables, etc.. As well as storing CSS " +"styling for IDs and Classes." +msgstr "" +"Used to store any HTML & CSS code that exists before the post/content " +"listings. Useful for div, ul, ol, tables, etc.. As well as storing CSS " +"styling for IDs and Classes." + +#: admin/post-list-meta-box-design.php:25 +msgid "" +"This where you design how your posts are going to display in the post list. " +"In here you can use HTML, CSS, PHP (requires the PHP shortcode), and the " +"plugin's internal shortcodes. Info can be found at the bottom, or by " +"clicking on the shortcode info found below \"List content\"." +msgstr "" +"This where you design how your posts are going to display in the post list. " +"In here you can use HTML, CSS, PHP (requires the PHP shortcode), and the " +"plugin's internal shortcodes. Info can be found at the bottom, or by " +"clicking on the shortcode info found below \"List content\"." + +#: admin/post-list-meta-box-design.php:29 +msgid "" +"Used for ending any elements that are still open, or to display a final " +"message to the users/visitors." +msgstr "" +"Used for ending any elements that are still open, or to display a final " +"message to the users/visitors." + +#: admin/post-list-meta-box-design.php:33 +msgid "" +"This container holds the HTML & CSS content and if no posts are found to be " +"listed in the preset. Then the preset post list will display this message. " +"If no Empty Message is found, then the post list will use the Default Empty " +"Message if enabled in the Plugin's Admin Settings. Otherwise, the plugin " +"will display nothing like it was originally set as. Please Note: if you are " +"using the Default Empty Message but you don't want to display anything in a " +"certain preset post list. Then simple create an empty element to fall back " +"on. For example, an empty \"span\" HTML element." +msgstr "" +"This container holds the HTML & CSS content and if no posts are found to be " +"listed in the preset. Then the preset post list will display this message. " +"If no Empty Message is found, then the post list will use the Default Empty " +"Message if enabled in the Plugin's Admin Settings. Otherwise, the plugin " +"will display nothing like it was originally set as. Please Note: if you are " +"using the Default Empty Message but you don't want to display anything in a " +"certain preset post list. Then simple create an empty element to fall back " +"on. For example, an empty \"span\" HTML element." + +#: admin/post-list-meta-box-design.php:51 +msgid "Before list:" +msgstr "Before list:" + +#: admin/post-list-meta-box-design.php:60 +msgid "List content:" +msgstr "List content:" + +#: admin/post-list-meta-box-design.php:64 +msgid "List of Shortcodes" +msgstr "List of Shortcodes" + +#: admin/post-list-meta-box-design.php:74 +msgid "After list:" +msgstr "After list:" + +#: admin/post-list-meta-box-design.php:83 +msgid "Empty Message:" +msgstr "Empty Message:" + +#: admin/post-list-meta-box-design.php:89 +msgid "Enable (Overwrites Default)" +msgstr "Enable (Overwrites Default)" + +#: admin/post-list-meta-box-design.php:102 +msgid "Edit Translation(s) of this Design." +msgstr "Edit Translation(s) of this Design." + +#: admin/post-list-meta-box-design.php:105 +msgid "" +"Please save the Post List in order to manage translations of this Design." +msgstr "" +"Please save the Post List in order to manage translations of this Design." + +#: admin/post-list-meta-box-filter.php:24 +msgid "" +"Each (jQuiry UI) accordion contains a separate individual post type. The " +"default post types built into WordPress are Post and Page. Any additional " +"post types are dynamically added in the manner WordPress does. Please Note: " +"Each post/page can have only one post type, which may explain why it has " +"been divided by post types." +msgstr "" +"Each (jQuiry UI) accordion contains a separate individual post type. The " +"default post types built into WordPress are Post and Page. Any additional " +"post types are dynamically added in the manner WordPress does. Please Note: " +"Each post/page can have only one post type, which may explain why it has " +"been divided by post types." + +#: admin/post-list-meta-box-filter.php:26 +msgid "" +"Each taxonomy is generally spit up in two sections, and divided into " +"separate tabs. Hierarchies (categories) are located on the left, and non-" +"hierarchies (tags) are located on the right." +msgstr "" +"Each taxonomy is generally spit up in two sections, and divided into " +"separate tabs. Hierarchies (categories) are located on the left, and non-" +"hierarchies (tags) are located on the right." + +#: admin/post-list-meta-box-filter.php:34 +msgid "" +"If selected, and more than one term is checked, then each term must be " +"required within the CPT/taxonomy in order to be displayed in the post list." +msgstr "" +"If selected, and more than one term is checked, then each term must be " +"required within the CPT/taxonomy in order to be displayed in the post list." + +#: admin/post-list-meta-box-filter.php:36 +msgid "" +"If selected, the post list preset will include any terms the current page/" +"post has within the CTP/taxonomy." +msgstr "" +"If selected, the post list preset will include any terms the current page/" +"post has within the CTP/taxonomy." + +#: admin/post-list-meta-box-filter.php:38 +msgid "When checked, any terms will be included within that CPT/taxonomy." +msgstr "When checked, any terms will be included within that CPT/taxonomy." + +#: admin/post-list-meta-box-filter.php:40 +msgid "" +"The numeric value of how many posts you want the post list to display. " +"Negative one (-1) will display all the posts that are available after " +"filtering." +msgstr "" +"The numeric value of how many posts you want the post list to display. " +"Negative one (-1) will display all the posts that are available after " +"filtering." + +#: admin/post-list-meta-box-filter.php:42 +msgid "" +"Choose which page properties to sort from. All of which are built in params " +"used in WP_Query." +msgstr "" +"Choose which page properties to sort from. All of which are built in params " +"used in WP_Query." + +#: admin/post-list-meta-box-filter.php:56 +msgid "" +"Uses the user permission via. user capabilities to determine what posts to " +"display in the post list to the visitor/user." +msgstr "" +"Uses the user permission via. user capabilities to determine what posts to " +"display in the post list to the visitor/user." + +#: admin/post-list-meta-box-filter.php:62 +msgid "" +"Add post/page IDs, seperated by a comma (,), will prevent those posts from " +"being added to the post list." +msgstr "" +"Add post/page IDs, seperated by a comma (,), will prevent those posts from " +"being added to the post list." + +#: admin/post-list-meta-box-filter.php:64 +msgid "" +"Meant for the built-in post type (Posts) function. When checked, this will " +"prevent sticky posts from always displaying at the top of the post list." +msgstr "" +"Meant for the built-in post type (Posts) function. When checked, this will " +"prevent sticky posts from always displaying at the top of the post list." + +#: admin/post-list-meta-box-filter.php:66 +msgid "" +"When checked, the current post being viewed will be excluded from the post " +"list." +msgstr "" +"When checked, the current post being viewed will be excluded from the post " +"list." + +#: admin/post-list-meta-box-filter.php:68 +msgid "" +"In the \"order that it is received\", each preset post list being viewed " +"will add the post IDs to a global exclude list built into APL. When checked, " +"the preset post list will add the post IDs (listed at the time) to the " +"exclude filter settings in WP_Query. This will remove any posts that have " +"already been displayed to the user by the APL plugin." +msgstr "" +"In the \"order that it is received\", each preset post list being viewed " +"will add the post IDs to a global exclude list built into APL. When checked, " +"the preset post list will add the post IDs (listed at the time) to the " +"exclude filter settings in WP_Query. This will remove any posts that have " +"already been displayed to the user by the APL plugin." + +#: admin/post-list-meta-box-filter.php:121 +msgid "Any / All Terms" +msgstr "Any / All Terms" + +#: admin/post-list-meta-box-filter.php:187 +msgid "" +"Adds the Current Page being displayed as a Parent Page, which will then add " +"those child pages." +msgstr "" +"Adds the Current Page being displayed as a Parent Page, which will then add " +"those child pages." + +#: admin/post-list-meta-box-filter.php:193 +msgid "Dynamic Parent Page" +msgstr "Dynamic Parent Page" + +#: admin/post-list-meta-box-filter.php:200 +#: admin/post-list-meta-box-filter.php:237 +msgid "Add" +msgstr "Add" + +#: admin/post-list-meta-box-filter.php:201 +#: admin/post-list-meta-box-filter.php:238 +#: admin/post-list-meta-box-filter.php:579 +msgid "ID" +msgstr "ID" + +#: admin/post-list-meta-box-filter.php:202 +#: admin/post-list-meta-box-filter.php:239 +msgid "Page Title" +msgstr "Page Title" + +#: admin/post-list-meta-box-filter.php:344 +msgid "Post Types" +msgstr "Post Types" + +#: admin/post-list-meta-box-filter.php:381 +msgid "Taxonomies" +msgstr "Taxonomies" + +#: admin/post-list-meta-box-filter.php:389 +msgid "Parent Pages" +msgstr "Parent Pages" + +#: admin/post-list-meta-box-filter.php:409 +msgid "Req. Taxonomies" +msgstr "Req. Taxonomies" + +#: admin/post-list-meta-box-filter.php:494 +msgid "Require Terms" +msgstr "Require Terms" + +#: admin/post-list-meta-box-filter.php:501 +msgid "Dynamic Terms" +msgstr "Dynamic Terms" + +#: admin/post-list-meta-box-filter.php:536 +msgid "List Amount:" +msgstr "List Amount:" + +#: admin/post-list-meta-box-filter.php:554 +msgid "Offset:" +msgstr "Offset:" + +#: admin/post-list-meta-box-filter.php:573 +msgid "Order By:" +msgstr "Order By:" + +#: admin/post-list-meta-box-filter.php:580 +msgid "Title" +msgstr "Title" + +#: admin/post-list-meta-box-filter.php:582 +msgid "Date" +msgstr "Date" + +#: admin/post-list-meta-box-filter.php:583 +msgid "Modified Date" +msgstr "Modified Date" + +#: admin/post-list-meta-box-filter.php:584 +msgid "Comments" +msgstr "Comments" + +#: admin/post-list-meta-box-filter.php:585 +msgid "Author" +msgstr "Author" + +#: admin/post-list-meta-box-filter.php:586 +msgid "Parent" +msgstr "Parent" + +#: admin/post-list-meta-box-filter.php:587 +msgid "Menu Order" +msgstr "Menu Order" + +#: admin/post-list-meta-box-filter.php:588 +msgid "Random" +msgstr "Random" + +#: admin/post-list-meta-box-filter.php:591 +msgid "Descending" +msgstr "Descending" + +#: admin/post-list-meta-box-filter.php:592 +msgid "Ascending" +msgstr "Ascending" + +#: admin/post-list-meta-box-filter.php:599 +msgid "Authors:" +msgstr "Authors:" + +#: admin/post-list-meta-box-filter.php:607 +msgid "From" +msgstr "From" + +#: admin/post-list-meta-box-filter.php:608 +msgid "Not From" +msgstr "Not From" + +#: admin/post-list-meta-box-filter.php:636 +msgid "Post Status:" +msgstr "Post Status:" + +#: admin/post-list-meta-box-filter.php:642 +msgid "Any" +msgstr "Any" + +#: admin/post-list-meta-box-filter.php:643 +msgid "Public" +msgstr "Public" + +#: admin/post-list-meta-box-filter.php:644 +msgid "Private (BETA)" +msgstr "Private (BETA)" + +#: admin/post-list-meta-box-filter.php:648 +msgid "Pending Review" +msgstr "Pending Review" + +#: admin/post-list-meta-box-filter.php:649 +msgid "Draft" +msgstr "Draft" + +#: admin/post-list-meta-box-filter.php:650 +msgid "Auto-Draft" +msgstr "Auto-Draft" + +#: admin/post-list-meta-box-filter.php:651 +msgid "Scheduled" +msgstr "Scheduled" + +#: admin/post-list-meta-box-filter.php:652 +msgid "Revisions" +msgstr "Revisions" + +#: admin/post-list-meta-box-filter.php:653 +msgid "Trash" +msgstr "Trash" + +#: admin/post-list-meta-box-filter.php:659 +msgid "User Perms:" +msgstr "User Perms:" + +#: admin/post-list-meta-box-filter.php:665 +msgid "Readable" +msgstr "Readable" + +#: admin/post-list-meta-box-filter.php:666 +msgid "Editable" +msgstr "Editable" + +#: admin/post-list-meta-box-filter.php:675 +msgid "Exclude Post by ID:" +msgstr "Exclude Post by ID:" + +#: admin/post-list-meta-box-filter.php:683 +msgid "Enable Sticky Posts:" +msgstr "Enable Sticky Posts:" + +#: admin/post-list-meta-box-filter.php:689 +msgid "Exclude Current Post:" +msgstr "Exclude Current Post:" + +#: admin/post-list-meta-box-filter.php:695 +msgid "Exclude Duplicate Posts:" +msgstr "Exclude Duplicate Posts:" + +#: admin/settings-meta-box-general.php:28 +msgid "Used for ignoring post types when creating/editing a post list." +msgstr "Used for ignoring post types when creating/editing a post list." + +#: admin/settings-meta-box-general.php:30 +msgid "" +"If \"No\" is selected, then the plugin's database data will not be removed " +"when the plugin is deactivated. When re-activated, the plugin data will " +"restored as it was left. Please Note: If the plugin is removed/uninstalled, " +"then the plugin's data will be removed regardless." +msgstr "" +"If \"No\" is selected, then the plugin's database data will not be removed " +"when the plugin is deactivated. When re-activated, the plugin data will " +"restored as it was left. Please Note: If the plugin is removed/uninstalled, " +"then the plugin's data will be removed regardless." + +#: admin/settings-meta-box-general.php:32 +msgid "Enable Default Empty Message: " +msgstr "Enable Default Empty Message: " + +#: admin/settings-meta-box-general.php:33 +msgid "" +"Used as a default option to use if no posts are found and the Empty Message " +"is empty within the preset post list." +msgstr "" +"Used as a default option to use if no posts are found and the Empty Message " +"is empty within the preset post list." + +#: admin/settings-meta-box-general.php:34 +msgid "Enable Global Exit (boolean): " +msgstr "Enable Global Exit (boolean): " + +#: admin/settings-meta-box-general.php:35 +msgid "" +"If enabled (yes), the all presets will fallback on the global/default Empty " +"Message." +msgstr "" +"If enabled (yes), the all presets will fallback on the global/default Empty " +"Message." + +#: admin/settings-meta-box-general.php:36 +msgid "Empty Message: " +msgstr "Empty Message: " + +#: admin/settings-meta-box-general.php:37 +msgid "" +"Contains the message that will be displayed if no posts are found. HTML and " +"CSS can be used." +msgstr "" +"Contains the message that will be displayed if no posts are found. HTML and " +"CSS can be used." + +#: admin/settings-meta-box-general.php:86 +msgid "Save Settings" +msgstr "Save Settings" + +#: admin/settings-meta-box-import-export.php:14 +msgid "" +"Exports the whole APL preset database/table. Illegal (< > : \" / \\ | , ? *) " +"characters cannot be used as the exported filename." +msgstr "" +"Exports the whole APL preset database/table. Illegal (< > : \" / \\ | , ? *) " +"characters cannot be used as the exported filename." + +#: admin/settings-meta-box-import-export.php:16 +msgid "" +"Imports data into the database. If there are any pre-existing data, you will " +"be prompted list of overwrite items." +msgstr "" +"Imports data into the database. If there are any pre-existing data, you will " +"be prompted list of overwrite items." + +#: admin/settings-meta-box-import-export.php:18 +msgid "" +"Designed to restore only the default preset table the plugin initially came " +"with." +msgstr "" +"Designed to restore only the default preset table the plugin initially came " +"with." + +#: admin/settings-meta-box-import-export.php:23 +msgid "Export Post List Database" +msgstr "Export Post List Database" + +#: admin/settings-meta-box-import-export.php:26 +msgid "Filename:" +msgstr "Filename:" + +#: admin/settings-meta-box-import-export.php:31 +msgid "Export" +msgstr "Export" + +#: admin/settings-meta-box-import-export.php:37 +msgid "Import Post List File" +msgstr "Import Post List File" + +#: admin/settings-meta-box-import-export.php:42 +msgid "Upload File:" +msgstr "Upload File:" + +#: admin/settings-meta-box-import-export.php:48 +msgid "Import" +msgstr "Import" + +#: admin/settings-meta-box-import-export.php:55 +msgid "Restore Defaults ( WIP )" +msgstr "Restore Defaults ( WIP )" + +#: admin/settings-meta-box-import-export.php:58 +msgid "Default Post Lists:" +msgstr "Default Post Lists:" + +#: admin/settings-meta-box-import-export.php:63 +msgid "" +"Restores the plugin's default preset table only, and will overwrite/add the " +"default Post Lists. This will not delete other Post Lists (as long as the " +"name isn't a default name)." +msgstr "" +"Restores the plugin's default preset table only, and will overwrite/add the " +"default Post Lists. This will not delete other Post Lists (as long as the " +"name isn't a default name)." + +#: admin/settings-meta-box-import-export.php:66 +msgid "" +"Note: This is currently a Work In Progress. The functionality is relatively " +"simple, however, many updates have taken place since then, and many of the " +"defaults are relatively old." +msgstr "" +"Note: This is currently a Work In Progress. The functionality is relatively " +"simple, however, many updates have taken place since then, and many of the " +"defaults are relatively old." + +#: admin/settings-meta-box-import-export.php:69 +msgid "Restore" +msgstr "Restore" + +#: admin/settings-page.php:19 +msgid "APL - Settings" +msgstr "APL - Settings" + +#: advanced-post-list.php:39 +msgid "This plugin requires Wordpress 2.0.2 or higher to operate. " +msgstr "This plugin requires Wordpress 2.0.2 or higher to operate. " + +#: advanced-post-list.php:40 +msgid "" +"Please update!" +msgstr "" +"Please update!" + +#: advanced-post-list.php:41 advanced-post-list.php:45 +msgid "Advanced Post List: Error" +msgstr "Advanced Post List: Error" + +#: advanced-post-list.php:44 +msgid "You are attempting to access this plugin directly." +msgstr "You are attempting to access this plugin directly." + +#: includes/class/class-apl-core.php:213 +msgid "APL Post Lists" +msgstr "APL Post Lists" + +#: includes/class/class-apl-core.php:214 +msgid "Post List" +msgstr "Post List" + +#: includes/class/class-apl-core.php:215 +msgctxt "List" +msgid "Add New" +msgstr "Add New" + +#: includes/class/class-apl-core.php:217 +msgid "Edit Post List" +msgstr "Edit Post List" + +#: includes/class/class-apl-core.php:218 +msgid "New Post List" +msgstr "New Post List" + +#: includes/class/class-apl-core.php:219 +msgid "View Post List" +msgstr "View Post List" + +#: includes/class/class-apl-core.php:220 +msgid "View Post Lists" +msgstr "View Post Lists" + +#: includes/class/class-apl-core.php:221 +msgid "Search Post Lists" +msgstr "Search Post Lists" + +#: includes/class/class-apl-core.php:222 +msgid "No Post Lists found" +msgstr "No Post Lists found" + +#: includes/class/class-apl-core.php:223 +msgid "No Post Lists found in Trash" +msgstr "No Post Lists found in Trash" + +#: includes/class/class-apl-core.php:224 includes/class/class-apl-core.php:283 +msgid ":" +msgstr ":" + +#: includes/class/class-apl-core.php:225 +msgid "All Post Lists" +msgstr "All Post Lists" + +#: includes/class/class-apl-core.php:226 +msgid "Post List Archives" +msgstr "Post List Archives" + +#: includes/class/class-apl-core.php:227 +msgid "Post List Attributes" +msgstr "Post List Attributes" + +#: includes/class/class-apl-core.php:228 +msgid "Insert into Post List" +msgstr "Insert into Post List" + +#: includes/class/class-apl-core.php:229 +msgid "Upload to this Post List" +msgstr "Upload to this Post List" + +#: includes/class/class-apl-core.php:230 +msgid "APL Post List" +msgstr "APL Post List" + +#: includes/class/class-apl-core.php:232 +msgid "APL Preset Post Lists." +msgstr "APL Preset Post Lists." + +#: includes/class/class-apl-core.php:272 +msgid "APL Designs" +msgstr "APL Designs" + +#: includes/class/class-apl-core.php:273 +msgid "Design" +msgstr "Design" + +#: includes/class/class-apl-core.php:274 +msgctxt "design" +msgid "Add New" +msgstr "Add New" + +#: includes/class/class-apl-core.php:275 +msgid "Add New Design" +msgstr "Add New Design" + +#: includes/class/class-apl-core.php:276 +msgid "Edit Design" +msgstr "Edit Design" + +#: includes/class/class-apl-core.php:277 +msgid "New Design" +msgstr "New Design" + +#: includes/class/class-apl-core.php:278 +msgid "View Design" +msgstr "View Design" + +#: includes/class/class-apl-core.php:279 +msgid "View Designs" +msgstr "View Designs" + +#: includes/class/class-apl-core.php:280 +msgid "Search Designs" +msgstr "Search Designs" + +#: includes/class/class-apl-core.php:281 +msgid "No Design found" +msgstr "No Design found" + +#: includes/class/class-apl-core.php:282 +msgid "No Design found in Trash" +msgstr "No Design found in Trash" + +#: includes/class/class-apl-core.php:284 +msgid "All Designs" +msgstr "All Designs" + +#: includes/class/class-apl-core.php:285 +msgid "Design Archives" +msgstr "Design Archives" + +#: includes/class/class-apl-core.php:286 +msgid "Design Attributes" +msgstr "Design Attributes" + +#: includes/class/class-apl-core.php:287 +msgid "Insert into Design" +msgstr "Insert into Design" + +#: includes/class/class-apl-core.php:288 +msgid "Upload to this Design" +msgstr "Upload to this Design" + +#: includes/class/class-apl-core.php:289 +msgid "APL Design" +msgstr "APL Design" + +#: includes/class/class-apl-core.php:291 +msgid "APL Designs for Preset Post Lists." +msgstr "APL Designs for Preset Post Lists." + +#: includes/class/class-apl-core.php:579 +#: includes/class/class-apl-updater.php:892 includes/functions.php:37 +msgid "Sorry, but no content is available at this time." +msgstr "Sorry, but no content is available at this time." + +#: includes/class/class-apl-core.php:681 +msgid "NOTICE: Shortcode name is missing. Ex [post_list name='example']" +msgstr "NOTICE: Shortcode name is missing. Ex [post_list name='example']" + +#: includes/class/class-apl-core.php:737 +msgid "NOTICE: Post list 'name' does not exist or is invalid." +msgstr "NOTICE: Post list 'name' does not exist or is invalid." + +#: includes/class/class-apl-shortcodes.php:1334 +msgid "" +"Error: Add define(\"APL_ALLOW_PHP\", true); to wp-config.php for " +"php_function to work." +msgstr "" +"Error: Add define(\"APL_ALLOW_PHP\", true); to wp-config.php for " +"php_function to work." + +#: includes/class/class-apl-shortcodes.php:1336 +msgid "Error: Change define(\"APL_ALLOW_PHP\", true); in " +msgstr "Error: Change define(\"APL_ALLOW_PHP\", true); in " + +#: includes/class/class-apl-shortcodes.php:1337 +msgid "wp-config.php for php_function to work." +msgstr "wp-config.php for php_function to work." + +#: includes/class/class-apl-shortcodes.php:1339 +msgid "Error: Name shortcode attribute must have a name. " +msgstr "Error: Name shortcode attribute must have a name. " + +#: includes/class/class-apl-shortcodes.php:1341 +msgid "" +"Error: Function does not exist. Check name in shortcode or is function name " +"is loaded." +msgstr "" +"Error: Function does not exist. Check name in shortcode or is function name " +"is loaded." + +#: includes/class/class-apl-shortcodes.php:1359 +msgid "Error: Unknown Error." +msgstr "Error: Unknown Error." + +#: includes/class/class-apl-shortcodes.php:1361 +msgid "defined APL_ALLOW_PHP: " +msgstr "defined APL_ALLOW_PHP: " + +#: includes/class/class-apl-shortcodes.php:1363 +msgid "$atts name:" +msgstr "$atts name:" + +#: includes/class/class-apl-shortcodes.php:1365 +msgid "$atts param:" +msgstr "$atts param:" + +#: includes/class/class-apl-updater.php:86 +msgid "" +"APL Updater Class Error: empty version and/or empty APL Options & APL Preset " +"Db is being passed to the Updater Class." +msgstr "" +"APL Updater Class Error: empty version and/or empty APL Options & APL Preset " +"Db is being passed to the Updater Class." + +#: includes/class/class-apl-widget.php:31 +msgid "Advanced Post Lists" +msgstr "Advanced Post Lists" + +#: includes/class/class-apl-widget.php:32 +msgid "Display preset post lists" +msgstr "Display preset post lists" + +#. Plugin URI of the plugin/theme +msgid "http://wordpress.org/plugins/advanced-post-list/" +msgstr "http://wordpress.org/plugins/advanced-post-list/" + +#. Description of the plugin/theme +msgid "" +"Create highly customizable post lists to display to your users and visitors. " +"Provides a wide array of static settings and dynamic features. Also supports " +"Custom Post Types and Taxonomies." +msgstr "" +"Create highly customizable post lists to display to your users and visitors. " +"Provides a wide array of static settings and dynamic features. Also supports " +"Custom Post Types and Taxonomies." + +#. Author of the plugin/theme +msgid "EkoJR" +msgstr "EkoJR" + +#. Author URI of the plugin/theme +msgid "http://ekojr.com" +msgstr "http://ekojr.com" diff --git a/languages/nl.po b/languages/nl.po new file mode 100644 index 0000000..57d1881 --- /dev/null +++ b/languages/nl.po @@ -0,0 +1,1080 @@ +msgid "" +msgstr "" +"Project-Id-Version: Advanced Post List\n" +"POT-Creation-Date: 2017-10-30 16:58-0700\n" +"PO-Revision-Date: 2017-10-30 16:58-0700\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: nl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 2.0.4\n" +"X-Poedit-Basepath: ..\n" +"X-Poedit-Flags-xgettext: --add-comments=translators:\n" +"X-Poedit-WPHeader: advanced-post-list.php\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;" +"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;" +"_nx_noop:3c,1,2;__ngettext_noop:1,2\n" +"X-Poedit-SearchPath-0: .\n" +"X-Poedit-SearchPathExcluded-0: *.js\n" + +#: admin/class-apl-admin.php:62 admin/class-apl-admin.php:74 +msgid "Cheatin' huh?" +msgstr "Wat ben jij aan het proberen?" + +#: admin/class-apl-admin.php:92 +#, fuzzy +msgid "You do not have admin capabilities in APL_Admin." +msgstr "U hoeft niet admin mogelijkheden in APL_Admin." + +#. Plugin Name of the plugin/theme +#: admin/class-apl-admin.php:214 +#, fuzzy +msgid "Advanced Post List" +msgstr "Geavanceerde Post lijst" + +#: admin/class-apl-admin.php:215 +#, fuzzy +msgid "Adv. Post List" +msgstr "Adv. Post lijst" + +#: admin/class-apl-admin.php:229 includes/class/class-apl-core.php:216 +#, fuzzy +msgid "Add New Post List" +msgstr "Nieuw Bericht toevoegen" + +#: admin/class-apl-admin.php:230 +msgid "Add New" +msgstr "Nieuwe rij aanmaken" + +#: admin/class-apl-admin.php:238 +#, fuzzy +msgid "APL Settings" +msgstr "APL-instellingen" + +#: admin/class-apl-admin.php:239 +msgid "Settings" +msgstr "Instellingen" + +#: admin/class-apl-admin.php:430 +msgid "Select Taxonomy" +msgstr "Selecteer Rangschikking" + +#: admin/class-apl-admin.php:431 +#, fuzzy +msgid "# of # taxonomies selected" +msgstr "# van # taxonomieën geselecteerd" + +#: admin/class-apl-admin.php:432 admin/post-list-meta-box-filter.php:578 +#: admin/post-list-meta-box-filter.php:606 +#: admin/post-list-meta-box-filter.php:641 +#: admin/post-list-meta-box-filter.php:664 +msgid "- None -" +msgstr "-Geen-" + +#: admin/class-apl-admin.php:433 admin/class-apl-admin.php:437 +#, fuzzy +msgid "# Selected" +msgstr "Geselecteerd" + +#: admin/class-apl-admin.php:434 +msgid "Select Status" +msgstr "Selecteer Status" + +#: admin/class-apl-admin.php:435 +msgid "Both" +msgstr "Beide" + +#: admin/class-apl-admin.php:436 admin/post-list-meta-box-filter.php:647 +msgid "Published" +msgstr "Gepubliceerd" + +#: admin/class-apl-admin.php:517 +msgid "Alert" +msgstr "Alarm" + +#: admin/class-apl-admin.php:518 +msgid "No Message to Display." +msgstr "Te tonen berichtmelding." + +#: admin/class-apl-admin.php:519 +#, fuzzy +msgid "Filename Required" +msgstr "Bestandsnaam vereist" + +#: admin/class-apl-admin.php:520 +#, fuzzy +msgid "A filename doesn't exist. \\n Please enter a filename before exporting." +msgstr "" +"Een bestandsnaam bestaat niet. \\n Voer een bestandsnaam in voordat u " +"exporteert." + +#: admin/class-apl-admin.php:521 +#, fuzzy +msgid "No file(s) selected. Please choose a JSON file to upload." +msgstr "Geen bestanden geselecteerd. Kies een JSON-bestand om te uploaden." + +#: admin/class-apl-admin.php:522 +msgid "No File" +msgstr "Geen bestand" + +#: admin/class-apl-admin.php:523 +#, fuzzy +msgid "Invalid file type. Please choose a JSON file to upload." +msgstr "Ongeldig bestandstype. Kies een JSON-bestand om te uploaden." + +#: admin/class-apl-admin.php:524 +msgid "Invalid File" +msgstr "Onjuist bestand" + +#: admin/class-apl-admin.php:525 +#, fuzzy +msgid "Data successfully imported." +msgstr "Gegevens succesvol geimporteerd." + +#: admin/class-apl-admin.php:526 +msgid "Complete" +msgstr "Markeer als geïmporteerd" + +#: admin/class-apl-admin.php:527 +#, fuzzy +msgid "Overwrite Presets" +msgstr "Voorinstellingen worden overschreven" + +#: admin/class-apl-admin.php:528 admin/class-apl-admin.php:534 +#, fuzzy +msgid "Illegal Characters" +msgstr "Verkeerde tekens" + +#: admin/class-apl-admin.php:529 admin/class-apl-admin.php:535 +#, fuzzy +msgid "Cannot use (< > : \" / \\ | , ? *)." +msgstr "Niet gebruiken (< >: \"/ \\ |,? *)." + +#: admin/class-apl-admin.php:530 admin/class-apl-admin.php:536 +#, fuzzy +msgid "Please rename your filename." +msgstr "Wijzig uw filename." + +#: admin/class-apl-admin.php:627 admin/post-list-meta-box-filter.php:581 +msgid "Slug" +msgstr "Afkorting" + +#: admin/class-apl-admin.php:628 +msgid "Shortcode" +msgstr "Shortcode" + +#: admin/class-apl-admin.php:704 +msgid "Filter Settings" +msgstr "Filterinstellingen" + +#: admin/class-apl-admin.php:712 admin/class-apl-admin.php:736 +msgid "Display Settings" +msgstr "Tonen/uitstraling instellingen" + +#: admin/class-apl-admin.php:756 +msgid "About" +msgstr "Over" + +#: admin/class-apl-admin.php:767 +msgid "General Settings" +msgstr "Algemene Instellingen" + +#: admin/class-apl-admin.php:775 +msgid "Import / Export" +msgstr "Importeren / Exporteren" + +#: admin/class-apl-admin.php:1267 +#, fuzzy +msgid "Version number is not present in imported file." +msgstr "Versienummer is niet aanwezig in het geïmporteerde bestand." + +#: admin/class-apl-admin.php:1419 admin/class-apl-admin.php:1795 +#, fuzzy +msgid "Any / All" +msgstr "Elke / alle" + +#: admin/post-list-meta-box-design.php:21 +#, fuzzy +msgid "" +"Used to store any HTML & CSS code that exists before the post/content " +"listings. Useful for div, ul, ol, tables, etc.. As well as storing CSS " +"styling for IDs and Classes." +msgstr "" +"Gebruikt voor het opslaan van elke HTML & CSS-code die, voordat de post/" +"inhoud aanbiedingen bestaat. Handig voor div, ul, ol, tabellen, enz... Naast " +"het opslaan van CSS styling voor pijpleidingen en instrumentatie en klassen." + +#: admin/post-list-meta-box-design.php:25 +#, fuzzy +msgid "" +"This where you design how your posts are going to display in the post list. " +"In here you can use HTML, CSS, PHP (requires the PHP shortcode), and the " +"plugin's internal shortcodes. Info can be found at the bottom, or by " +"clicking on the shortcode info found below \"List content\"." +msgstr "" +"Dit waar u ontwerpen hoe uw berichten gaan weer te geven in de lijst met " +"berichten. U kunt hier HTML, CSS, PHP (vereist de shortcode PHP), en van de " +"plugin interne shortcodes. Info kan worden gevonden op de bodem, of door te " +"klikken op de info van de shortcode vinden onder \"De inhoud van de lijst\"." + +#: admin/post-list-meta-box-design.php:29 +#, fuzzy +msgid "" +"Used for ending any elements that are still open, or to display a final " +"message to the users/visitors." +msgstr "" +"Gebruikt voor het beëindigen van alle elementen die nog open zijn of om een " +"laatste boodschap aan de gebruikers/bezoekers weer te geven." + +#: admin/post-list-meta-box-design.php:33 +msgid "" +"This container holds the HTML & CSS content and if no posts are found to be " +"listed in the preset. Then the preset post list will display this message. " +"If no Empty Message is found, then the post list will use the Default Empty " +"Message if enabled in the Plugin's Admin Settings. Otherwise, the plugin " +"will display nothing like it was originally set as. Please Note: if you are " +"using the Default Empty Message but you don't want to display anything in a " +"certain preset post list. Then simple create an empty element to fall back " +"on. For example, an empty \"span\" HTML element." +msgstr "" + +#: admin/post-list-meta-box-design.php:51 +#, fuzzy +msgid "Before list:" +msgstr "Voordat de lijst:" + +#: admin/post-list-meta-box-design.php:60 +msgid "List content:" +msgstr "Lijstinhoud:" + +#: admin/post-list-meta-box-design.php:64 +#, fuzzy +msgid "List of Shortcodes" +msgstr "Lijst van Shortcodes" + +#: admin/post-list-meta-box-design.php:74 +#, fuzzy +msgid "After list:" +msgstr "Na lijst:" + +#: admin/post-list-meta-box-design.php:83 +msgid "Empty Message:" +msgstr "Leeg bericht:" + +#: admin/post-list-meta-box-design.php:89 +#, fuzzy +msgid "Enable (Overwrites Default)" +msgstr "Inschakelen (overschrijft de standaard)" + +#: admin/post-list-meta-box-design.php:102 +#, fuzzy +msgid "Edit Translation(s) of this Design." +msgstr "Bewerken Translation(s) van dit ontwerp." + +#: admin/post-list-meta-box-design.php:105 +#, fuzzy +msgid "" +"Please save the Post List in order to manage translations of this Design." +msgstr "Sla de lijst met berichten om beheer vertalingen van dit ontwerp." + +#: admin/post-list-meta-box-filter.php:24 +#, fuzzy +msgid "" +"Each (jQuiry UI) accordion contains a separate individual post type. The " +"default post types built into WordPress are Post and Page. Any additional " +"post types are dynamically added in the manner WordPress does. Please Note: " +"Each post/page can have only one post type, which may explain why it has " +"been divided by post types." +msgstr "" +"Elke accordeon (jQuiry UI) bevat een afzonderlijke individuele post type. De " +"standaard post typen ingebouwd in WordPress zijn Post en pagina. Eventuele " +"extra post typen worden dynamisch toegevoegd op de wijze die WordPress doet. " +"Let op: Elke post/pagina kan slechts één post type, wat kan verklaren waarom " +"het is opgedeeld door bericht typen hebben." + +#: admin/post-list-meta-box-filter.php:26 +#, fuzzy +msgid "" +"Each taxonomy is generally spit up in two sections, and divided into " +"separate tabs. Hierarchies (categories) are located on the left, and non-" +"hierarchies (tags) are located on the right." +msgstr "" +"Elke taxonomie is over het algemeen spugen in twee secties, en onderverdeeld " +"in afzonderlijke tabbladen. Hiërarchieën (categorieën) bevinden zich aan de " +"linkerkant, en niet-hiërarchieën (tags) bevinden zich aan de rechterkant." + +#: admin/post-list-meta-box-filter.php:34 +#, fuzzy +msgid "" +"If selected, and more than one term is checked, then each term must be " +"required within the CPT/taxonomy in order to be displayed in the post list." +msgstr "" +"Indien geselecteerd, en meer dan één termijn is gecontroleerd en vervolgens " +"elke term moet binnen de CPT/taxonomie vereist om te kunnen worden " +"weergegeven in de lijst met berichten." + +#: admin/post-list-meta-box-filter.php:36 +#, fuzzy +msgid "" +"If selected, the post list preset will include any terms the current page/" +"post has within the CTP/taxonomy." +msgstr "" +"Indien geselecteerd, zal de post lijst voorinstelling eventuele voorwaarden " +"die de huidige pagina/post binnen de CTP/taxonomie heeft omvatten." + +#: admin/post-list-meta-box-filter.php:38 +#, fuzzy +msgid "When checked, any terms will be included within that CPT/taxonomy." +msgstr "" +"Wanneer gecontroleerd, worden eventuele voorwaarden opgenomen binnen dat CPT/" +"taxonomie." + +#: admin/post-list-meta-box-filter.php:40 +#, fuzzy +msgid "" +"The numeric value of how many posts you want the post list to display. " +"Negative one (-1) will display all the posts that are available after " +"filtering." +msgstr "" +"De numerieke waarde van hoeveel berichten u wilt dat de lijst met berichten " +"om weer te geven. Negatieve één (-1) alle berichten die beschikbaar na " +"filtering zijn wordt weergegeven." + +#: admin/post-list-meta-box-filter.php:42 +#, fuzzy +msgid "" +"Choose which page properties to sort from. All of which are built in params " +"used in WP_Query." +msgstr "" +"Kies welke paginaeigenschappen om te sorteren. Die allemaal zijn opgebouwd " +"uit params gebruikt in WP_Query." + +#: admin/post-list-meta-box-filter.php:56 +#, fuzzy +msgid "" +"Uses the user permission via. user capabilities to determine what posts to " +"display in the post list to the visitor/user." +msgstr "" +"Gebruikt de gebruiker toestemming via. de mogelijkheden van de gebruiker om " +"te bepalen wat posten weer te geven in de lijst van de post voor de bezoeker/" +"gebruiker." + +#: admin/post-list-meta-box-filter.php:62 +#, fuzzy +msgid "" +"Add post/page IDs, seperated by a comma (,), will prevent those posts from " +"being added to the post list." +msgstr "" +"Voeg bericht/pagina-IDs, gescheiden door een komma (,), voorkomt u dat deze " +"posten worden toegevoegd aan de lijst met berichten." + +#: admin/post-list-meta-box-filter.php:64 +#, fuzzy +msgid "" +"Meant for the built-in post type (Posts) function. When checked, this will " +"prevent sticky posts from always displaying at the top of the post list." +msgstr "" +"Bedoeld voor de functie van de ingebouwde post-type (posten). Wanneer " +"ingeschakeld, zal dit verhinderen kleverige posten altijd aan de bovenkant " +"van de lijst met berichten weer te geven." + +#: admin/post-list-meta-box-filter.php:66 +#, fuzzy +msgid "" +"When checked, the current post being viewed will be excluded from the post " +"list." +msgstr "" +"Wanneer ingeschakeld, zal het huidige bericht wordt bekeken worden " +"uitgesloten van de lijst met berichten." + +#: admin/post-list-meta-box-filter.php:68 +#, fuzzy +msgid "" +"In the \"order that it is received\", each preset post list being viewed " +"will add the post IDs to a global exclude list built into APL. When checked, " +"the preset post list will add the post IDs (listed at the time) to the " +"exclude filter settings in WP_Query. This will remove any posts that have " +"already been displayed to the user by the APL plugin." +msgstr "" +"In de \"bestellen dat zij is ontvangen\", elke lijst met vooraf ingestelde " +"berichten wordt bekeken zal de post id's toevoegen aan een lijst van de " +"globale uitsluiten APL ingebouwd. Wanneer ingeschakeld, zal de lijst met " +"vooraf ingestelde berichten het bericht id's (vermeld op het moment) " +"toevoegt aan de filterinstellingen uitsluiten in WP_Query. Hiermee " +"verwijdert u alle posten die al zijn weergegeven aan de gebruiker door de " +"APL-plugin." + +#: admin/post-list-meta-box-filter.php:121 +#, fuzzy +msgid "Any / All Terms" +msgstr "Elke / alle voorwaarden" + +#: admin/post-list-meta-box-filter.php:187 +#, fuzzy +msgid "" +"Adds the Current Page being displayed as a Parent Page, which will then add " +"those child pages." +msgstr "" +"De huidige pagina wordt weergegeven als een bovenliggende pagina, die " +"vervolgens die onderliggende pagina's toevoegen zal toegevoegd." + +#: admin/post-list-meta-box-filter.php:193 +#, fuzzy +msgid "Dynamic Parent Page" +msgstr "Dynamische bovenliggende pagina" + +#: admin/post-list-meta-box-filter.php:200 +#: admin/post-list-meta-box-filter.php:237 +msgid "Add" +msgstr "Toevoegen" + +#: admin/post-list-meta-box-filter.php:201 +#: admin/post-list-meta-box-filter.php:238 +#: admin/post-list-meta-box-filter.php:579 +msgid "ID" +msgstr "ID" + +#: admin/post-list-meta-box-filter.php:202 +#: admin/post-list-meta-box-filter.php:239 +msgid "Page Title" +msgstr "Paginatitel" + +#: admin/post-list-meta-box-filter.php:344 +msgid "Post Types" +msgstr "Berichtsoorten" + +#: admin/post-list-meta-box-filter.php:381 +msgid "Taxonomies" +msgstr "Taxonomiën" + +#: admin/post-list-meta-box-filter.php:389 +#, fuzzy +msgid "Parent Pages" +msgstr "Bovenliggende pagina 's" + +#: admin/post-list-meta-box-filter.php:409 +#, fuzzy +msgid "Req. Taxonomies" +msgstr "Req. taxonomieën" + +#: admin/post-list-meta-box-filter.php:494 +#, fuzzy +msgid "Require Terms" +msgstr "Voorwaarden vereisen" + +#: admin/post-list-meta-box-filter.php:501 +#, fuzzy +msgid "Dynamic Terms" +msgstr "Dynamische voorwaarden" + +#: admin/post-list-meta-box-filter.php:536 +#, fuzzy +msgid "List Amount:" +msgstr "Lijst bedrag:" + +#: admin/post-list-meta-box-filter.php:554 +msgid "Offset:" +msgstr "Offset:" + +#: admin/post-list-meta-box-filter.php:573 +msgid "Order By:" +msgstr "Bestelling:" + +#: admin/post-list-meta-box-filter.php:580 +msgid "Title" +msgstr "Titel" + +#: admin/post-list-meta-box-filter.php:582 +msgid "Date" +msgstr "Datum" + +#: admin/post-list-meta-box-filter.php:583 +msgid "Modified Date" +msgstr "Aangepaste datum" + +#: admin/post-list-meta-box-filter.php:584 +msgid "Comments" +msgstr "Reacties" + +#: admin/post-list-meta-box-filter.php:585 +msgid "Author" +msgstr "Schrijver" + +#: admin/post-list-meta-box-filter.php:586 +msgid "Parent" +msgstr "Puder" + +#: admin/post-list-meta-box-filter.php:587 +msgid "Menu Order" +msgstr "Menu volgorde" + +#: admin/post-list-meta-box-filter.php:588 +msgid "Random" +msgstr "Willekeurig" + +#: admin/post-list-meta-box-filter.php:591 +msgid "Descending" +msgstr "Aflopend" + +#: admin/post-list-meta-box-filter.php:592 +msgid "Ascending" +msgstr "Oplopend" + +#: admin/post-list-meta-box-filter.php:599 +msgid "Authors:" +msgstr "Auteurs:" + +#: admin/post-list-meta-box-filter.php:607 +msgid "From" +msgstr "Van" + +#: admin/post-list-meta-box-filter.php:608 +#, fuzzy +msgid "Not From" +msgstr "Niet uit" + +#: admin/post-list-meta-box-filter.php:636 +msgid "Post Status:" +msgstr "Bericht status:" + +#: admin/post-list-meta-box-filter.php:642 +msgid "Any" +msgstr "Geen voorkeur" + +#: admin/post-list-meta-box-filter.php:643 +msgid "Public" +msgstr "Openbare" + +#: admin/post-list-meta-box-filter.php:644 +#, fuzzy +msgid "Private (BETA)" +msgstr "Privé (BETA)" + +#: admin/post-list-meta-box-filter.php:648 +msgid "Pending Review" +msgstr "Wachtend op review" + +#: admin/post-list-meta-box-filter.php:649 +msgid "Draft" +msgstr "Concept" + +#: admin/post-list-meta-box-filter.php:650 +msgid "Auto-Draft" +msgstr "Auto ontwerp / Auto Draft" + +#: admin/post-list-meta-box-filter.php:651 +msgid "Scheduled" +msgstr "Ingepland" + +#: admin/post-list-meta-box-filter.php:652 +msgid "Revisions" +msgstr "Revisies" + +#: admin/post-list-meta-box-filter.php:653 +msgid "Trash" +msgstr "Prullenbak" + +#: admin/post-list-meta-box-filter.php:659 +#, fuzzy +msgid "User Perms:" +msgstr "Permanenten van de gebruiker:" + +#: admin/post-list-meta-box-filter.php:665 +msgid "Readable" +msgstr "Leesbaar" + +#: admin/post-list-meta-box-filter.php:666 +msgid "Editable" +msgstr "Bewerken" + +#: admin/post-list-meta-box-filter.php:675 +msgid "Exclude Post by ID:" +msgstr "Post-ID uitsluiten:" + +#: admin/post-list-meta-box-filter.php:683 +#, fuzzy +msgid "Enable Sticky Posts:" +msgstr "Inschakelen van kleverige posten:" + +#: admin/post-list-meta-box-filter.php:689 +msgid "Exclude Current Post:" +msgstr "Sluit huidig bericht uit:" + +#: admin/post-list-meta-box-filter.php:695 +#, fuzzy +msgid "Exclude Duplicate Posts:" +msgstr "Duplicate Posts uitsluiten:" + +#: admin/settings-meta-box-general.php:28 +#, fuzzy +msgid "Used for ignoring post types when creating/editing a post list." +msgstr "" +"Gebruikt voor het negeren van de post typen bij het maken/bewerken van een " +"lijst met berichten." + +#: admin/settings-meta-box-general.php:30 +#, fuzzy +msgid "" +"If \"No\" is selected, then the plugin's database data will not be removed " +"when the plugin is deactivated. When re-activated, the plugin data will " +"restored as it was left. Please Note: If the plugin is removed/uninstalled, " +"then the plugin's data will be removed regardless." +msgstr "" +"Als \"Nee\" is geselecteerd, zullen dan van de plugin databasegegevens niet " +"worden verwijderd wanneer de plugin wordt gedeactiveerd. Wanneer opnieuw " +"wordt geactiveerd, zal de plugin gegevens hersteld als het bleef. Let op: " +"Als de plugin verwijderd/verwijderd is, dan van de plugin zal worden " +"gegevens verwijderd ongeacht." + +#: admin/settings-meta-box-general.php:32 +msgid "Enable Default Empty Message: " +msgstr "Lege standaardbericht inschakelen: " + +#: admin/settings-meta-box-general.php:33 +#, fuzzy +msgid "" +"Used as a default option to use if no posts are found and the Empty Message " +"is empty within the preset post list." +msgstr "" +"Gebruikt als een standaardoptie te gebruiken als geen berichten zijn " +"gevonden en de lege bericht leeg in de lijst met vooraf ingestelde berichten " +"is." + +#: admin/settings-meta-box-general.php:34 +msgid "Enable Global Exit (boolean): " +msgstr "Inschakelen van globale Exit (boolean): " + +#: admin/settings-meta-box-general.php:35 +#, fuzzy +msgid "" +"If enabled (yes), the all presets will fallback on the global/default Empty " +"Message." +msgstr "" +"Als ingeschakeld (Ja), zal het alle voorinstellingen terugval op de " +"wereldwijde/default leeg bericht." + +#: admin/settings-meta-box-general.php:36 +msgid "Empty Message: " +msgstr "Leeg bericht: " + +#: admin/settings-meta-box-general.php:37 +#, fuzzy +msgid "" +"Contains the message that will be displayed if no posts are found. HTML and " +"CSS can be used." +msgstr "" +"Bevat het bericht dat wordt weergegeven als er geen berichten worden " +"gevonden. HTML en CSS kan worden gebruikt." + +#: admin/settings-meta-box-general.php:86 +msgid "Save Settings" +msgstr "Instellingen opslaan" + +#: admin/settings-meta-box-import-export.php:14 +#, fuzzy +msgid "" +"Exports the whole APL preset database/table. Illegal (< > : \" / \\ | , ? *) " +"characters cannot be used as the exported filename." +msgstr "" +"Export de hele APL voorinstelling/databasetabel. Illegale (< >: \"/ \\ |,? " +"*) tekens mogen niet worden gebruikt als het geëxporteerde bestand." + +#: admin/settings-meta-box-import-export.php:16 +#, fuzzy +msgid "" +"Imports data into the database. If there are any pre-existing data, you will " +"be prompted list of overwrite items." +msgstr "" +"Met deze methode importeert gegevens in de database. Als er geen bestaande " +"gegevens zijn, wordt u gevraagd lijst overschrijven de items." + +#: admin/settings-meta-box-import-export.php:18 +#, fuzzy +msgid "" +"Designed to restore only the default preset table the plugin initially came " +"with." +msgstr "" +"Ontwikkeld om te herstellen van alleen de vooraf ingestelde standaardtabel " +"die de plugin in eerste instantie kwam met." + +#: admin/settings-meta-box-import-export.php:23 +#, fuzzy +msgid "Export Post List Database" +msgstr "Post lijst Database exporteren" + +#: admin/settings-meta-box-import-export.php:26 +msgid "Filename:" +msgstr "bestandsnaam: " + +#: admin/settings-meta-box-import-export.php:31 +msgid "Export" +msgstr "Exporteer" + +#: admin/settings-meta-box-import-export.php:37 +#, fuzzy +msgid "Import Post List File" +msgstr "Post lijst importbestand" + +#: admin/settings-meta-box-import-export.php:42 +msgid "Upload File:" +msgstr "Bestand uploaden: " + +#: admin/settings-meta-box-import-export.php:48 +msgid "Import" +msgstr "Importeer" + +#: admin/settings-meta-box-import-export.php:55 +#, fuzzy +msgid "Restore Defaults ( WIP )" +msgstr "Herstellen van de standaardwaarden (WIP)" + +#: admin/settings-meta-box-import-export.php:58 +#, fuzzy +msgid "Default Post Lists:" +msgstr "Post standaardlijsten:" + +#: admin/settings-meta-box-import-export.php:63 +#, fuzzy +msgid "" +"Restores the plugin's default preset table only, and will overwrite/add the " +"default Post Lists. This will not delete other Post Lists (as long as the " +"name isn't a default name)." +msgstr "" +"Herstelt van de plugin standaard voorinstelling alleen indienen, en zullen " +"overschrijven/toevoegen de standaard Post lijst. Dit zal niet verwijderen " +"andere Post lijsten (zolang de naam niet een standaardnaam)." + +#: admin/settings-meta-box-import-export.php:66 +#, fuzzy +msgid "" +"Note: This is currently a Work In Progress. The functionality is relatively " +"simple, however, many updates have taken place since then, and many of the " +"defaults are relatively old." +msgstr "" +"Opmerking: Dit is momenteel een Work In Progress. De functionaliteit is " +"relatief eenvoudig, echter veel updates hebben plaatsgevonden sindsdien, en " +"veel van de standaardinstellingen zijn vrij oude." + +#: admin/settings-meta-box-import-export.php:69 +msgid "Restore" +msgstr "Zet terug" + +#: admin/settings-page.php:19 +#, fuzzy +msgid "APL - Settings" +msgstr "APL - instellingen" + +#: advanced-post-list.php:39 +#, fuzzy +msgid "This plugin requires Wordpress 2.0.2 or higher to operate. " +msgstr "Deze plugin vereist Wordpress 2.0.2 of hoger om te opereren." + +#: advanced-post-list.php:40 +#, fuzzy +msgid "" +"Please update!" +msgstr "" +"Update " +"alstublieft" + +#: advanced-post-list.php:41 advanced-post-list.php:45 +#, fuzzy +msgid "Advanced Post List: Error" +msgstr "Geavanceerde Post lijst: fout" + +#: advanced-post-list.php:44 +#, fuzzy +msgid "You are attempting to access this plugin directly." +msgstr "U wilt deze plugin direct benaderen." + +#: includes/class/class-apl-core.php:213 +#, fuzzy +msgid "APL Post Lists" +msgstr "APL Post lijsten" + +#: includes/class/class-apl-core.php:214 +msgid "Post List" +msgstr "Post lijst" + +#: includes/class/class-apl-core.php:215 +msgctxt "List" +msgid "Add New" +msgstr "Nieuwe rij aanmaken" + +#: includes/class/class-apl-core.php:217 +#, fuzzy +msgid "Edit Post List" +msgstr "Post lijst bewerken" + +#: includes/class/class-apl-core.php:218 +#, fuzzy +msgid "New Post List" +msgstr "Lijst met nieuwe berichten" + +#: includes/class/class-apl-core.php:219 +#, fuzzy +msgid "View Post List" +msgstr "Bekijk de lijst van de Post" + +#: includes/class/class-apl-core.php:220 +#, fuzzy +msgid "View Post Lists" +msgstr "Lijsten van de Post bekijken" + +#: includes/class/class-apl-core.php:221 +#, fuzzy +msgid "Search Post Lists" +msgstr "Zoek Post lijsten" + +#: includes/class/class-apl-core.php:222 +#, fuzzy +msgid "No Post Lists found" +msgstr "Geen lijsten gevonden" + +#: includes/class/class-apl-core.php:223 +#, fuzzy +msgid "No Post Lists found in Trash" +msgstr "Geen Post lijsten gevonden in Prullenbak" + +#: includes/class/class-apl-core.php:224 includes/class/class-apl-core.php:283 +msgid ":" +msgstr ":" + +#: includes/class/class-apl-core.php:225 +#, fuzzy +msgid "All Post Lists" +msgstr "Alle Post lijsten" + +#: includes/class/class-apl-core.php:226 +#, fuzzy +msgid "Post List Archives" +msgstr "Archieven discussiegroep" + +#: includes/class/class-apl-core.php:227 +#, fuzzy +msgid "Post List Attributes" +msgstr "Post lijst kenmerken" + +#: includes/class/class-apl-core.php:228 +#, fuzzy +msgid "Insert into Post List" +msgstr "In bericht invoegen" + +#: includes/class/class-apl-core.php:229 +#, fuzzy +msgid "Upload to this Post List" +msgstr "Uploaden naar deze Post lijst" + +#: includes/class/class-apl-core.php:230 +#, fuzzy +msgid "APL Post List" +msgstr "APL Post lijst" + +#: includes/class/class-apl-core.php:232 +#, fuzzy +msgid "APL Preset Post Lists." +msgstr "APL voorinstelling Post lijst." + +#: includes/class/class-apl-core.php:272 +#, fuzzy +msgid "APL Designs" +msgstr "APL ontwerpen" + +#: includes/class/class-apl-core.php:273 +msgid "Design" +msgstr "Ontwerp" + +#: includes/class/class-apl-core.php:274 +msgctxt "design" +msgid "Add New" +msgstr "Nieuwe rij aanmaken" + +#: includes/class/class-apl-core.php:275 +#, fuzzy +msgid "Add New Design" +msgstr "Nieuw Ontwerp" + +#: includes/class/class-apl-core.php:276 +msgid "Edit Design" +msgstr "Ontwerp bewerken" + +#: includes/class/class-apl-core.php:277 +#, fuzzy +msgid "New Design" +msgstr "Nieuw Ontwerp" + +#: includes/class/class-apl-core.php:278 +msgid "View Design" +msgstr "Ontwerp Bekijken" + +#: includes/class/class-apl-core.php:279 +#, fuzzy +msgid "View Designs" +msgstr "Weergave ontwerpen" + +#: includes/class/class-apl-core.php:280 +#, fuzzy +msgid "Search Designs" +msgstr "Zoek ontwerpen" + +#: includes/class/class-apl-core.php:281 +#, fuzzy +msgid "No Design found" +msgstr "Geen model gevonden" + +#: includes/class/class-apl-core.php:282 +#, fuzzy +msgid "No Design found in Trash" +msgstr "Geen model gevonden in Prullenbak" + +#: includes/class/class-apl-core.php:284 +#, fuzzy +msgid "All Designs" +msgstr "Alle ontwerpen" + +#: includes/class/class-apl-core.php:285 +#, fuzzy +msgid "Design Archives" +msgstr "Ontwerp archieven" + +#: includes/class/class-apl-core.php:286 +#, fuzzy +msgid "Design Attributes" +msgstr "Ontwerp kenmerken" + +#: includes/class/class-apl-core.php:287 +#, fuzzy +msgid "Insert into Design" +msgstr "Invoegen van Design" + +#: includes/class/class-apl-core.php:288 +#, fuzzy +msgid "Upload to this Design" +msgstr "Uploaden naar dit ontwerp" + +#: includes/class/class-apl-core.php:289 +#, fuzzy +msgid "APL Design" +msgstr "APL Design" + +#: includes/class/class-apl-core.php:291 +#, fuzzy +msgid "APL Designs for Preset Post Lists." +msgstr "APL ontwerpen voor vooraf ingestelde Post lijsten." + +#: includes/class/class-apl-core.php:579 +#: includes/class/class-apl-updater.php:892 includes/functions.php:37 +#, fuzzy +msgid "Sorry, but no content is available at this time." +msgstr "Sorry, maar er is op dit moment geen inhoud beschikbaar." + +#: includes/class/class-apl-core.php:681 +#, fuzzy +msgid "NOTICE: Shortcode name is missing. Ex [post_list name='example']" +msgstr "" +"Let op: De naam van de Shortcode ontbreekt. Ex [post_list naam = 'voorbeeld']" + +#: includes/class/class-apl-core.php:737 +#, fuzzy +msgid "NOTICE: Post list 'name' does not exist or is invalid." +msgstr "AANKONDIGING: Post lijst 'naam' bestaat niet of is ongeldig." + +#: includes/class/class-apl-shortcodes.php:1334 +#, fuzzy +msgid "" +"Error: Add define(\"APL_ALLOW_PHP\", true); to wp-config.php for " +"php_function to work." +msgstr "" +"Fout: Toevoegen define (\"APL_ALLOW_PHP\", true); aan wp-config.php voor " +"php_function om te werken." + +#: includes/class/class-apl-shortcodes.php:1336 +msgid "Error: Change define(\"APL_ALLOW_PHP\", true); in " +msgstr "Fout: Verandering define (\"APL_ALLOW_PHP\", true); in " + +#: includes/class/class-apl-shortcodes.php:1337 +#, fuzzy +msgid "wp-config.php for php_function to work." +msgstr "wp-config.php voor php_function om te werken." + +#: includes/class/class-apl-shortcodes.php:1339 +msgid "Error: Name shortcode attribute must have a name. " +msgstr "Fout: Naam shortcode kenmerk moet een naam hebben. " + +#: includes/class/class-apl-shortcodes.php:1341 +#, fuzzy +msgid "" +"Error: Function does not exist. Check name in shortcode or is function name " +"is loaded." +msgstr "" +"Fout: Functie does not exist. Zie de naam in de shortcode of is functienaam " +"wordt geladen." + +#: includes/class/class-apl-shortcodes.php:1359 +#, fuzzy +msgid "Error: Unknown Error." +msgstr "Fout: Onbekende fout." + +#: includes/class/class-apl-shortcodes.php:1361 +msgid "defined APL_ALLOW_PHP: " +msgstr "gedefinieerde APL_ALLOW_PHP: " + +#: includes/class/class-apl-shortcodes.php:1363 +#, fuzzy +msgid "$atts name:" +msgstr "$atts naam:" + +#: includes/class/class-apl-shortcodes.php:1365 +#, fuzzy +msgid "$atts param:" +msgstr "$atts param:" + +#: includes/class/class-apl-updater.php:86 +#, fuzzy +msgid "" +"APL Updater Class Error: empty version and/or empty APL Options & APL Preset " +"Db is being passed to the Updater Class." +msgstr "" +"APL Updater klasse Error: lege versie en/of lege APL opties & APL " +"voorinstelling Db wordt doorgegeven aan de Updater-klasse." + +#: includes/class/class-apl-widget.php:31 +#, fuzzy +msgid "Advanced Post Lists" +msgstr "Geavanceerde Post lijsten" + +#: includes/class/class-apl-widget.php:32 +#, fuzzy +msgid "Display preset post lists" +msgstr "Vooraf ingestelde post lijsten weergeven" + +#. Plugin URI of the plugin/theme +#, fuzzy +msgid "http://wordpress.org/plugins/advanced-post-list/" +msgstr "http://WordPress.org/plugins/Advanced-post-list/" + +#. Description of the plugin/theme +#, fuzzy +msgid "" +"Create highly customizable post lists to display to your users and visitors. " +"Provides a wide array of static settings and dynamic features. Also supports " +"Custom Post Types and Taxonomies." +msgstr "" +"Hoogst klantgerichte post lijsten weer te geven aan uw gebruikers en " +"bezoekers maken. Biedt een breed scala aan instellingen voor statische en " +"dynamische eigenschappen. Ook ondersteunt aangepaste bericht typen en " +"taxonomieën." + +#. Author of the plugin/theme +#, fuzzy +msgid "EkoJR" +msgstr "EkoJR" + +#. Author URI of the plugin/theme +#, fuzzy +msgid "http://ekojr.com" +msgstr "http://ekojr.com" diff --git a/readme.txt b/readme.txt index f04a263..24f2fa1 100644 --- a/readme.txt +++ b/readme.txt @@ -1,28 +1,34 @@ === Advanced Post List === Contributors: EkoJr Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=VFUYQGQ7VXEDC -Tags: Advanced, Post List, Categories, Category, Children, Children Pages, Content, Custom, Custom Post Type, Custom Post Types, Custom Taxonomy, Custom Taxonomies, Draft, Draft Posts, Excerpt, Filter, Future, Future Posts, Links, List, Links, News, Page, Pages, Parent, Parent Pages, Popular Posts, Post, Posts, Private, Private Posts, Related, Related Posts, Recent, Recent Posts, Shortcode, Shortcodes, Simple, Tag, Tags, Thumbnail, Widget, Widgets -Requires at least: 2.0.2 -Tested up to: 4.8 -Stable tag: 0.3.7 +Tags: Post List, Tool, Editor, Featured, Related Posts, Author, Authors, Auto, Automate, Builder, Categories, Category, Child Pages, CMS, Content, Comment, Comments, CPT, CSS, Custom, Custom Post Type, Custom Post Types, Custom Taxonomy, Custom Taxonomies, Design, Developer, Draft, Draft Posts, Excerpt, Feature, Featured, Featured Content, Filter, Future, Future Posts, HTML, Image, Images, Links, List, Links, Magazine, Magazines, News, Page, Pages, Parent, Parent Pages, Photos, PHP, Popular Posts, Post, Posts, Private, Private Posts, Programming, Published, Related Post, Related Posts, Recent, Recent Post, Recent Posts, Shortcode, Shortcodes, Simple, Tag, Tags, Thumbnail, Web Design, Web Development, Webmaster, Widget, Widgets, WPML +Requires at least: 4.5 +Tested up to: 4.8.2 +Stable tag: 0.4.0 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html -Create Post Lists that are highly customizable in both design and query filter. Which can then be placed multiple times without showing duplicates. +Post List builder with highly customizable filter & custom designs. Whether it's displaying Recent Posts, Related Posts, Dynamic Posts, or a list of posts in general. == Description == -[wp kpl]: https://wordpress.org/plugins/kalins-post-list/ - "WordPress.org - Kalin's Post List" -[wp apl support]: https://wordpress.org/support/plugin/advanced-post-list - "WordPress.org - Support for APL" -[github issues]: https://github.com/Advanced-Post-List/advanced-post-list/issues - "Report an Issue" -[github wiki]: https://github.com/Advanced-Post-List/advanced-post-list/wiki - "Learn or Contribute to APL" -[wiki shortcodes]: https://github.com/Advanced-Post-List/advanced-post-list/wiki/Internal-Shortcode-Page - "Documentaion for Internal Shortcodes" - -Advanced Post Lists (APL) sets itself apart from being “Just Another Post List Plugin” by giving admins the most amount of control when displaying Recent Posts, Related Posts, Future Posts, or a list of posts in general. However, there is a learning curve. +[wp kpl]: https://wordpress.org/plugins/kalins-post-list/ + "WordPress.org - Kalin's Post List" +[apl getting started]: https://support.advancedpostlist.com/getting-started/ + "Getting Started w/ APL" +[apl qa]: https://support.advancedpostlist.com/qa/ + "Questions & Answers" +[apl docs]: https://support.advancedpostlist.com/documentation/ + "APL Documentation" +[apl shortcodes]: https://support.advancedpostlist.com/doc/internal-shortcodes/ + "List of Internal Shortcodes" +[wp apl support]: https://wordpress.org/support/plugin/advanced-post-list + "WordPress.org - Support for APL" +[github issues]: https://github.com/Advanced-Post-List/advanced-post-list/issues + "Report an Issue" +[github wiki]: https://github.com/Advanced-Post-List/advanced-post-list/wiki + "Learn or Contribute to APL" + +This tool functions much like a Post List builder to give Admins the most amount of control over managing content to display. Developed with Web Designers & Developers in mind, makes this a highly customizable tool to have around. However, there is a sharp learning curve for most. You must know: @@ -32,22 +38,31 @@ You must know: * JavaScript * PHP -In many ways, APL is designed to act much like The Loop which is most notable in Themes, but APL takes that concept and turns it into an Admin tool that can easily be changed, moved, or added/removed. This eliminates much of the backend work, and prevents being limited to what is hardcoded into a theme. +## Summary -APL accomplishes 3 main types of tasks. Filter, Design, and Placement. +Advanced Post List (aka APL) is designed to operate much like The Loop in WordPress; which is most notable in Themes. However, that concept is taken and turned into an Admin tool that can easily be changed, moved, or added/removed. This eliminates much of the backend work, and prevents being limited to what is hardcoded into a theme. -# Filter +This also makes multiple Featured Content with different configurations more of a breeze, and the complexity of it is a challenge that APL achieves unlike any other. -* **Custom Post Type and Taxonomy Support** - Displays Posts/Pages from custom post types, taxonomies, and terms. This includes other plugins, but may not be compatibly supported. +APL can accomplish a large degree of variations, but can be broken down to 3 main types of tasks. With Filter, Design, and Placement, here are some of the key features. + +### Filter + +* **Custom Post Type and Taxonomy Support (CPT)** - Displays Posts/Pages from custom post types, taxonomies, and terms. This includes other plugins with post data. but may store its data differently than post_content. (**Advanced Users, see php_function shortcode.**) * **Enhanced/Diverse Queries** - Capable of diverse filter configuration when displaying posts. This feature allows... - * Different Post Types -> Taxonomies query configurations. - * Multiple Page Parents from multiple Post Types. -* **Dynamic Filters (Terms & Page Parents)** - Grabs values to filter by that is based on the current page being viewed. _Ex. Displaying Related Posts in a Header, Footer, Sidebar, etc.._ -* **Show Content from Published, Private, Future, etc.** - Display content on the frontend so users don’t have to navigate to the admin side. Allowing private landing pages to be created. _Note: Further development may be required._ + * Cross Filtering with Custom Post Types. + * Diverse Post Types -> Taxonomies query configurations. + * Multiple Query configurations with include and require. +* **Optimized with Complex Queries** - Once deemed an Achilles Heel to WP Query, steps are taken to reduce the server load as much as possible. +* **Dynamic Filters** - Grabs values to filter by based on the current posts/pages being viewed. _Ex. Displaying Related Posts in a Header, Footer, Sidebar, etc.._ +* **Show Content from Published, Private, Future, etc.** - This is a *development feature* and may not provide intended results. Display content on the frontend so users don’t have to navigate to the admin side. Allowing private landing pages to be created. _Note: Requires advanced knowledge on how WP Query and User Perms operate._ -## Design -* **Internal Shortcodes** - Primarily used to add various data from a given Post/Page, but the capabilities is rather extensive, and being able to extend to custom PHP functions the options are practically limitless. [See documentation for a full list & details][wiki shortcodes]. +### Design + +* **Layout and Style 99.9% Customizable** - There's nearly no limitations to the design, with some exceptions that may surface with (Child) Theme's CSS. This does require some knowledge in Web Design. *Note: This is NOT to be confused with Drag and Drop UI/UX.* +* **Internal Shortcodes** - Adds various data from Post object, and is one of the extensive features. Being able to extend to shortcodes with custom PHP functions make the possibilities practically limitless. [See full list & details][apl shortcodes]. +* **Encapsulated for Zero Conflicts** - With a large number of shortcodes on any given site. Isolating Internal Shortcodes to its own instance eliminates any plugin conflicts. * **Custom Formats to Loop ( The Loop )** - Themes follow this concept, but APL turns that concept into a tool. The “List Content” loop, as well as the before & after, is where most of the work is done with preset HTML, CSS, JS, & PHP designs. It is also optional to set an Empty Message (No Posts Found) to display. ### Placement @@ -56,9 +71,23 @@ APL accomplishes 3 main types of tasks. Filter, Design, and Placement. * **Sidebar Widget** - Easier to use. However, adding post list shortcodes to the text sidebar also produces the same results. * **PHP Hardcode** - For more extensive design work. There is a public function for displaying Preset Post Lists where WordPress support and functions for admins aren’t fully present. -This is an evolved version of [Kalins Post List][wp kpl]. Most of the credit for the idea behind APL goes to that plugin. As you may have noticed, APL is still in the development stages of its target version (1.0.0). +## Other Plugins Tested/Supported + +There's various plugins that offer a unique capability, and some of which APL can use as intended, but there are also some don't. Here is a list of popular plugins that have been tested and verified by Advanced Post List. + +* **Advanced Custom Fields** - Requires php_function shortcode. +* **WPML** - With WordPress Multilingual installed, additional Designs can be created for rendering a Post List in different languages. Posts/Pages are handled automatically and will display content in various languages. + +APL is open to development requests and welcomes those willing to report on any issues. + +## Help & Support -APL’s Documentation is located on [GitHub Wiki][github wiki] (WIP). Which is also open for others to contribute. +Currently, information can be found in 2 different locations. This is due to recent changes, and is only temporary. + +* [Getting Started][apl getting started] +* [Documentation][apl docs] + * [Internal Shortcodes][apl shortcodes] +* [GitHub Wiki][github wiki] Questions/Bug Report submit thread / ticket at [WordPress][wp apl support] or [GitHub Issue / Tickets][github issues]. @@ -70,21 +99,51 @@ Questions/Bug Report submit thread / ticket at [WordPress][wp apl support] or [G == Frequently Asked Questions == -= Where is the settings page? = -Inside your admin dashboard under Settings->Admin Post List. - -= How do I display the post list that I created? = -You need to locate and copy the shortcode which is in the Advance Post List - Settings page on the saved preset table. Then create a page/post and paste the shortcode on your page/post (e.g. [post_list name='some-preset-name']) += For FAQ = +Go to [Q&A][apl qa]. == Screenshots == -1. A few samples of the plugin. -2. Insert saved presets via shortcodes to display it on a page/post. -3. A basic view of the Admin UI. -4. General options and support. +1. Using a simple shortcode, you can display amazing content. +2. A Few more examples. +3. Complex lists coupled together. +4. Admin Screen for All Post Lists. +5. Admin UI for Creating/Editing Post lists. +6. Admin Screen for Settings. == Changelog == += 0.4.0 = +* Added APL_Post_List Class for post data database structure with presets. +* Added APL_Design Class for post data database structure with preset designs; before, content, after, & empty message. +* Changed Preset data to use post data database structure (APL_Post_List & APL_Design). +* Added Admin Singleton Class. +* Changed to Custom Admin Menu. +* Added New Admin templates and multiple UI changes. +* Changed Info/Help to Tooltips instead of Dialogs. +* Added Post_Type filter by 'Any'. +* Changed 'Require Taxonomy' to 'Require Taxonomies' as a Post Type based filter instead. +* Added Sort by 'None' and 'Slug'. +* Added Post Status filter by 'None' and 'Any'. +* Added Perms filter by 'None'. +* Added Offset filter. +* Added additional Notice to front-end if attribute 'name' in [post_list] is invalid or missing. +* Added Sanitazion to shortcode attribute 'name'; ex. [post_list name=""]. +* Fixed Link attribute in post_category & post_tags shortcode. +* Added additional checks with php_function shortcode. +* Changed General Settings to Settings API w/ Meta Boxes. +* Added Ignore Post Types on Admin Post List screen. +* Changed/Fixed Exporting and Importing. +* Fixed possible defect with Plugin Options not being initiated. +* Added jQuery (UI) compatability. +* Removed jQuery UI Theme setting from APL Options. +* Changed Updater Class param items to update to an array. +* Changed version check to a hook method. +* Added WPML Support. +* Added Internalization for translations. +* Added non-class Functions file for common functions. +* Added hooks.php file to store custom hook examples. + = 0.3.7 = * Fixed warning with load_plugin_textdomain. @@ -181,7 +240,6 @@ You need to locate and copy the shortcode which is in the Advance Post List - Se * Changed Back-up Procedures to Use Both a Handler and a Final Function. * Changed Import File Uploads from Single to Multiple Files. - = 0.3.b5 = * Added ‘Any/All’ term setting to taxonomies. * Added User/Visitor Permissions. @@ -199,7 +257,6 @@ You need to locate and copy the shortcode which is in the Advance Post List - Se * Changed Admin Dialogs. * Changed jQuery register script location. - = 0.3.b4 = * Fixed dynamics with post lists with 'Include Terms' within taxonomy and 'Current Page' post parent. * Fixed excluding current page. @@ -264,95 +321,96 @@ You need to locate and copy the shortcode which is in the Advance Post List - Se == Upgrade Notice == += 0.4.0 = +* Please be sure to Back Up the website. Large database update will occur. +* Completely new Admin UI. +* WPML Support and Plugin Internalization. + = 0.3.6 = -Stable Release. Changed File Structure which may cause a PHP object error -( Please report PHP errors ). If upgrading from 0.2, make sure to back -up the plugin data and website. +* Stable Release. Changed File Structure which may cause a PHP object error ( Please report PHP errors ). +* If upgrading from 0.2, make sure to back up the plugin data and website. = 0.3.5 = -Stable Release. Changed File Structure which may cause a PHP object error -( Please report PHP errors ). If upgrading from 0.2, make sure to back -up the plugin data and website. +* Stable Release. Changed File Structure which may cause a PHP object error ( Please report PHP errors ). +* If upgrading from 0.2, make sure to back up the plugin data and website. = 0.3.4 = -Stable Release. If upgrading from 0.2, make sure to back up the plugin data -and website. +* Stable Release. If upgrading from 0.2, make sure to back up the plugin data and website. = 0.3.3 = -Stable Release. If upgrading from 0.2, make sure to back up the plugin data +* Stable Release. If upgrading from 0.2, make sure to back up the plugin data and website. = 0.3.2 = -Stable Release. If upgrading from 0.2, make sure to back up the plugin data +* Stable Release. If upgrading from 0.2, make sure to back up the plugin data and website. = 0.3.1 = -Stable Release. If upgrading from 0.2, make sure to back up the plugin data +* Stable Release. If upgrading from 0.2, make sure to back up the plugin data and website. = 0.3.0 = -Stable Release. If upgrading from 0.2, make sure to back up the plugin data +* Stable Release. If upgrading from 0.2, make sure to back up the plugin data and website. = 0.3.b9 = -Beta Version. Candidate for Stable Release (0.3.0). If upgrading from 0.2, make -sure you back up the plugin data and/or website. +* Beta Version. Candidate for Stable Release (0.3.0). +* If upgrading from 0.2, make sure you back up the plugin data and/or website. = 0.3.b8 = -Beta Version. If upgrading from 0.2, make sure you back up the plugin data +* Beta Version. If upgrading from 0.2, make sure you back up the plugin data and/or website. This update includes a couple major and blocker bugs to the Admin UI. Further development may be required before releasing the stable version (0.3.0). = 0.3.b7 = -Beta Version. If upgrading from 0.2, make sure you back up the plugin data +* Beta Version. If upgrading from 0.2, make sure you back up the plugin data and/or website. This update includes a couple major and blocker bugs to the Admin UI. Further testing is required before releasing the stable version. = 0.3.b6 = -Beta Version. As always, make sure you back up your website since +* Beta Version. As always, make sure you back up your website since 0.3 has a couple of database updates. This version fixes some critical issues when being used on a large site. Fixes to the Backup feature have also been included in this. = 0.3.b5 = -Beta Version. Beta 5 has another database upgrade, so it is recommended you +* Beta Version. Beta 5 has another database upgrade, so it is recommended you backup your data, and use a test site first. No issues with the database have been posted. Contains additional filter settings that are built-in the WP_Query params, and added a couple custom function. Also fixed a few issues. Look at the changelog for more details. = 0.3.b4 = -Beta Version. It is recommended you backup, but no issues with the database +* Beta Version. It is recommended you backup, but no issues with the database have been posted. Contains fixes for querying posts, and deactivation. = 0.3.b3 = -Beta Version. It is recommended you back up data prior to upgrading.Fixed some +* Beta Version. It is recommended you back up data prior to upgrading.Fixed some 'strict' errors that were being tossed that could cause an issue. = 0.3.b2 = -Beta Version. It is recommended you back up data prior to upgrading. A few +* Beta Version. It is recommended you back up data prior to upgrading. A few added preset settings. Fixed a problem with script handling that was interfering with built-in scripting. = 0.3.b1 = -Beta Version. Please back up your plugin data prior to upgrading. This version +* Beta Version. Please back up your plugin data prior to upgrading. This version introduces custom post type and taxonomy support. Along with a few added settings. = 0.3.a1 = -Alpha Version. Please back up your plugin data prior to upgrading. This version +* Alpha Version. Please back up your plugin data prior to upgrading. This version introduces custom post type and taxonomy support. Along with a few added settings. = 0.2.0 = -Upgrade adds a new export/import feature to back up your data, and fixes the +* Upgrade adds a new export/import feature to back up your data, and fixes the PHP hardcode, exclude current, and TextArea element. See change log for more details. = 0.1.1 = -The require() functions in advanced-post-list.php didn't have a dynamic value -set. +* The require() functions in advanced-post-list.php didn't have a dynamic value set. = 0.1.0 = -First stable version. +* First stable version. diff --git a/wpml-config.xml b/wpml-config.xml new file mode 100644 index 0000000..ed8f335 --- /dev/null +++ b/wpml-config.xml @@ -0,0 +1,169 @@ + + + apl_post_list + apl_design + + + apl_content + apl_before + apl_after + apl_post_type + apl_tax_query + apl_post_parent__in + apl_post_parent_dynamic + apl_posts_per_page + apl_offset + apl_order_by + apl_order + apl_author__bool + apl_author__in + apl_post_status + apl_perm + apl_post__not_in + apl_ignore_sticky_posts + apl_pl_exclude_current + apl_pl_exclude_dupes + apl_pl_apl_design + apl_empty + + + + + + + + + ID + + + post_name + + + post_slug + + + post_title + + + post_permalink + + + guid + + + post_date + + format + + + + post_date_gmt + + format + + + + post_modified + + format + + + + post_modified_gmt + + format + + + + post_author + + label + + + + post_thumb + + size + extract + + + + post_content + + + post_excerpt + + length + + + + comment_count + + + post_comments + + before + after + + + + post_parent + + link + + + + post_type + + label + + + + post_categories + + delimiter + links + + + + post_tags + + delimiter + links + + + + post_terms + + taxonomy + delimiter + links + max + empty_message + + + + post_meta + + name + + + + php_funtion + + name + param + + + + item_number + + offset + increment + + + + final_end + + + \ No newline at end of file