Skip to content

Commit

Permalink
fix the TBD versions that I missed
Browse files Browse the repository at this point in the history
  • Loading branch information
JiveDig committed Dec 12, 2024
1 parent 27dcb3a commit c5e12eb
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/admin/dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ function mai_change_plugin_dependency_text( $actions ) {
* Disables ACF updates settings page.
*
* @since 2.32.0
* @since TBD Disabled so uses can update their own licenses.
* @since 2.35.0 Disabled so users can update their own licenses.
*
* @param bool $value The current value.
*
Expand Down
2 changes: 1 addition & 1 deletion lib/customize/output.php
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ function mai_add_classic_editor_styles() {
* @link http://wordpress.stackexchange.com/a/226623/2807
*
* @since 2.25.0
* @since TBD Added transient for CSS.
* @since 2.35.0 Added transient for CSS.
*
* @return void
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/fields/grid-display.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @since 0.1.0
* @since 2.25.6 Added admin check.
* @since TBD Added ajax check.
* @since 2.35.0 Added ajax check.
*
* @param array $field Field array.
*
Expand Down Expand Up @@ -53,7 +53,7 @@ function mai_acf_load_show( $field ) {
*
* @since 0.1.0
* @since 2.25.6 Added admin check.
* @since TBD Added ajax check.
* @since 2.35.0 Added ajax check.
*
* @param array $args Field args.
*
Expand Down
2 changes: 1 addition & 1 deletion lib/fields/grid-layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @since 2.4.0
* @since 2.25.6 Added admin check.
* @since TBD Added ajax check.
* @since 2.35.0 Added ajax check.
*
* @param array $field The existing field.
*
Expand Down
4 changes: 2 additions & 2 deletions lib/fields/icons.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
* @since 0.1.0
* @since 2.25.6 Added admin check.
* @since TBD Added ajax check.
* @since 2.35.0 Added ajax check.
*
* @param array $field The ACF field.
*
Expand All @@ -46,7 +46,7 @@ function mai_load_icon_choices( $field ) {
*
* @since 0.1.0
* @since 2.25.6 Added admin check.
* @since TBD Added ajax check.
* @since 2.35.0 Added ajax check.
*
* @param array $field Field args.
*
Expand Down
2 changes: 1 addition & 1 deletion lib/fields/validate.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* We need this because we wrongly used custom field keys that don't start with `field_`.
* Our engine blocks use `mai_` and plugin blocks use `maicca_', `maipub_`, etc., so we check for `mai`.
*
* @since TBD
* @since 2.35.0
*
* @param bool $bool The result.
* @param string $id The identifier.
Expand Down
48 changes: 43 additions & 5 deletions lib/fields/wp-term-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @since 2.21.0
* @since 2.25.6 Added admin check.
* @since TBD Added ajax check.
* @since 2.35.0 Added ajax check.
*
* @param array $field The existing field array.
*
Expand All @@ -34,13 +34,45 @@ function mai_grid_load_taxonomy_field( $field ) {
return $field;
}

add_filter( 'acf/prepare_field/key=mai_grid_block_taxonomy', 'mai_grid_prepare_taxonomy_field' );
/**
* Load taxonomy choices based on existing saved field value.
* Since we're using ajax to load choices, we need to load the saved value as an initial choice.
*
* @link https://github.com/maithemewp/mai-engine/issues/93
*
* @since 2.35.0
*
* @param array $field The existing field array.
*
* @return array
*/
function mai_grid_prepare_taxonomy_field( $field ) {
// Bail if not in admin. No AJAX check here because we need this on page load.
if ( ! is_admin() ) {
return $field;
}

if ( $field['value'] ) {
foreach ( $field['value'] as $taxonomy ) {
$taxonomy = get_taxonomy( $taxonomy );

if ( $taxonomy ) {
$field['choices'] = [ $taxonomy->name => $taxonomy->label ];
}
}
}

return $field;
}

add_filter( 'acf/load_field/key=mai_grid_block_tax_include', 'mai_grid_load_include_terms_field' );
add_filter( 'acf/load_field/key=mai_grid_block_tax_exclude', 'mai_grid_load_include_terms_field' );
/**
* Sets taxonomy based on the block taxonomies field, when the include/exclude fields are initially loaded.
*
* @since 2.27.0
* @since TBD Added ajax check.
* @since 2.35.0 Added ajax check.
*
* @param array $field
*
Expand Down Expand Up @@ -83,7 +115,7 @@ function mai_grid_load_include_terms_field( $field ) {
* @since 0.1.0
* @since 2.25.6 Added admin check.
* @since 2.27.0 Force first taxonomy. See #631.
* @since TBD Added ajax check.
* @since 2.35.0 Added ajax check.
*
* @param array $args Field args.
*
Expand Down Expand Up @@ -115,7 +147,7 @@ function mai_acf_get_terms( $args, $field, $post_id ) {
*
* @since 0.1.0
* @since 2.25.6 Added admin check.
* @since TBD Added ajax check.
* @since 2.35.0 Added ajax check.
*
* @param array $args Field args.
*
Expand Down Expand Up @@ -156,7 +188,7 @@ function mai_acf_get_term_parents( $args ) {
*
* @since 2.22.0
* @since 2.25.6 Added admin check.
* @since TBD Added ajax check.
* @since 2.35.0 Added ajax check.
*
* @link https://www.powderkegwebdesign.com/fantastic-way-allow-searching-id-advanced-custom-fields-objects/
*
Expand Down Expand Up @@ -195,6 +227,12 @@ function mai_acf_get_terms_by_id( $args, $field, $post_id ) {
* @return array
*/
function mai_get_taxonomy_choices() {
static $choices = null;

if ( ! is_null( $choices ) ) {
return $choices;
}

$choices = [];
$taxonomies = get_taxonomies(
[
Expand Down
2 changes: 1 addition & 1 deletion lib/support/facetwp.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/**
* Forces FacetWP support for when the MPG has `facetwp-template` class.
*
* @since TBD
* @since 2.35.0
*
* @param array $query_args WP_Query args.
* @param array $args Mai Post Grid args.
Expand Down

0 comments on commit c5e12eb

Please sign in to comment.