Plugin Directory

Changeset 2883308


Ignore:
Timestamp:
03/20/2023 08:57:09 AM (3 years ago)
Author:
integromat
Message:

Work with custom taxonomies only

Location:
integromat-connector
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • integromat-connector/tags/1.5.5/class/class-rest-request.php

    r2783423 r2883308  
    4242
    4343    /**
    44      * @param WP_REST_Response $response
     44     * @param /WP_REST_Response $response
    4545     * @param array            $response_data
    4646     */
  • integromat-connector/tags/1.5.5/class/class-user.php

    r2783423 r2883308  
    1111     */
    1212    public static function get_administrator_user() {
    13         $users = get_users();
     13        $users = get_users( array( 'role__in' => array( 'administrator') ) );
    1414        if ( empty( $users ) ) {
    1515            return 0;
  • integromat-connector/tags/1.5.5/index.php

    r2793954 r2883308  
    33/**
    44 * @package Integromat_Connector
    5  * @version 1.5.4
     5 * @version 1.5.5
    66 */
    77
     
    1111Author: Celonis s.r.o.
    1212Author URI: https://www.make.com/en?utm_source=wordpress&utm_medium=partner&utm_campaign=wordpress-partner-make
    13 Version: 1.5.4
     13Version: 1.5.5
    1414*/
    1515
  • integromat-connector/tags/1.5.5/readme.txt

    r2793954 r2883308  
    33Tags: rest, api, rest api, integromat, endpoint, endpoints, meta, data, meta_data, make
    44Requires at least: 5.0
    5 Tested up to:  6.0.1
     5Tested up to:  6.1.1
    66Requires PHP: 5.6
    7 Stable tag: 1.5.4
     7Stable tag: 1.5.5
    88License: GPLv2 or later
    99
  • integromat-connector/tags/1.5.5/settings/class-controller.php

    r2783423 r2883308  
    5656}
    5757
     58add_filter( "pre_update_option_integromat_api_options_taxonomy", function ($new_value, $old_value) {
     59
     60    $updated_taxonomies = empty( $new_value ) ? array() : $new_value;
     61
     62    $taxonomies = get_taxonomies( array( '_builtin' => false, 'public' => true ) );
     63    foreach ( $taxonomies as $key ) {
     64        if ( ! in_array( $key, array_keys( $updated_taxonomies ) ) ) {
     65            $updated_taxonomies[ $key ] = "0";
     66        }
     67    }
     68
     69    return $updated_taxonomies;
     70
     71}, 10, 2 );
     72
    5873add_filter(
    5974    'register_taxonomy_args',
    60     function ( $args, $taxonomy_name ) {
    61         $o = get_option( 'integromat_api_options_taxonomy' );
    62         // Option doesn't exist, run with default params.
    63         $not_exists = is_bool( $o ) && $o === false;
    64         // otherwise run with settings.
    65         if ( false === $not_exists ) {
    66             $enabled_taxonomies = empty( $o ) ? array() : array_keys( $o );
    67             if ( in_array( $taxonomy_name, $enabled_taxonomies ) ) {
    68                 $args['show_in_rest'] = true;
    69             } else {
    70                 $args['show_in_rest'] = false;
    71             }
     75    function ($args, $taxonomy_name) {
     76
     77        if ( ( isset( $args['_builtin'] ) && $args['_builtin'] ) || ( isset( $args['public'] ) && ! $args['public'] ) ) {
     78            return $args;
     79        }
     80
     81        $optn = get_option( 'integromat_api_options_taxonomy' );
     82
     83        if ( false === $optn ) {
     84            // option doesn't exist in db, run with everything default.
     85            return $args;
     86        }
     87
     88        $saved_taxonomies = empty( $optn ) ? array() : array_keys( $optn );
     89
     90        if ( in_array( $taxonomy_name, $saved_taxonomies ) ) {
     91            $args['show_in_rest'] = (boolean) $optn[ $taxonomy_name ];
    7292        }
    7393        return $args;
  • integromat-connector/tags/1.5.5/settings/object-types/custom-taxonomy.php

    r2783423 r2883308  
    1818    );
    1919
    20     $taxonomies = get_taxonomies();
     20    $taxonomies = get_taxonomies(array('_builtin' => false, 'public' => true));
    2121    foreach ( $taxonomies as $tax_slug ) {
    2222        add_settings_field(
     
    2525            function ( $args ) {
    2626                $taxonomy = get_taxonomy( $args['label_for'] );
    27                 $options  = get_option( 'integromat_api_options_taxonomy' );
    28                 // check if taxonomy is generally enabled.
    29                 $is_enabled = empty( $taxonomy->show_in_rest ) ? false : true;
    30                 // check if taxonomy enabled in plugin settings.
    31                 $is_enabled_in_plugin = isset( $options[ $args['label_for'] ] ) && $options[ $args['label_for'] ] == 1 ? true : false;
    32                 $checked              = $is_enabled || $is_enabled_in_plugin ? 'checked' : '';
     27                $checked  = !empty( $taxonomy->show_in_rest ) ? 'checked' : '';
    3328                ?>
    3429                    <input type="checkbox"
  • integromat-connector/trunk/class/class-rest-request.php

    r2783423 r2883308  
    4242
    4343    /**
    44      * @param WP_REST_Response $response
     44     * @param /WP_REST_Response $response
    4545     * @param array            $response_data
    4646     */
  • integromat-connector/trunk/class/class-user.php

    r2783423 r2883308  
    1111     */
    1212    public static function get_administrator_user() {
    13         $users = get_users();
     13        $users = get_users( array( 'role__in' => array( 'administrator') ) );
    1414        if ( empty( $users ) ) {
    1515            return 0;
  • integromat-connector/trunk/index.php

    r2793954 r2883308  
    33/**
    44 * @package Integromat_Connector
    5  * @version 1.5.4
     5 * @version 1.5.5
    66 */
    77
     
    1111Author: Celonis s.r.o.
    1212Author URI: https://www.make.com/en?utm_source=wordpress&utm_medium=partner&utm_campaign=wordpress-partner-make
    13 Version: 1.5.4
     13Version: 1.5.5
    1414*/
    1515
  • integromat-connector/trunk/readme.txt

    r2793954 r2883308  
    33Tags: rest, api, rest api, integromat, endpoint, endpoints, meta, data, meta_data, make
    44Requires at least: 5.0
    5 Tested up to:  6.0.1
     5Tested up to:  6.1.1
    66Requires PHP: 5.6
    7 Stable tag: 1.5.4
     7Stable tag: 1.5.5
    88License: GPLv2 or later
    99
  • integromat-connector/trunk/settings/class-controller.php

    r2783423 r2883308  
    5656}
    5757
     58add_filter( "pre_update_option_integromat_api_options_taxonomy", function ($new_value, $old_value) {
     59
     60    $updated_taxonomies = empty( $new_value ) ? array() : $new_value;
     61
     62    $taxonomies = get_taxonomies( array( '_builtin' => false, 'public' => true ) );
     63    foreach ( $taxonomies as $key ) {
     64        if ( ! in_array( $key, array_keys( $updated_taxonomies ) ) ) {
     65            $updated_taxonomies[ $key ] = "0";
     66        }
     67    }
     68
     69    return $updated_taxonomies;
     70
     71}, 10, 2 );
     72
    5873add_filter(
    5974    'register_taxonomy_args',
    60     function ( $args, $taxonomy_name ) {
    61         $o = get_option( 'integromat_api_options_taxonomy' );
    62         // Option doesn't exist, run with default params.
    63         $not_exists = is_bool( $o ) && $o === false;
    64         // otherwise run with settings.
    65         if ( false === $not_exists ) {
    66             $enabled_taxonomies = empty( $o ) ? array() : array_keys( $o );
    67             if ( in_array( $taxonomy_name, $enabled_taxonomies ) ) {
    68                 $args['show_in_rest'] = true;
    69             } else {
    70                 $args['show_in_rest'] = false;
    71             }
     75    function ($args, $taxonomy_name) {
     76
     77        if ( ( isset( $args['_builtin'] ) && $args['_builtin'] ) || ( isset( $args['public'] ) && ! $args['public'] ) ) {
     78            return $args;
     79        }
     80
     81        $optn = get_option( 'integromat_api_options_taxonomy' );
     82
     83        if ( false === $optn ) {
     84            // option doesn't exist in db, run with everything default.
     85            return $args;
     86        }
     87
     88        $saved_taxonomies = empty( $optn ) ? array() : array_keys( $optn );
     89
     90        if ( in_array( $taxonomy_name, $saved_taxonomies ) ) {
     91            $args['show_in_rest'] = (boolean) $optn[ $taxonomy_name ];
    7292        }
    7393        return $args;
  • integromat-connector/trunk/settings/object-types/custom-taxonomy.php

    r2783423 r2883308  
    1818    );
    1919
    20     $taxonomies = get_taxonomies();
     20    $taxonomies = get_taxonomies(array('_builtin' => false, 'public' => true));
    2121    foreach ( $taxonomies as $tax_slug ) {
    2222        add_settings_field(
     
    2525            function ( $args ) {
    2626                $taxonomy = get_taxonomy( $args['label_for'] );
    27                 $options  = get_option( 'integromat_api_options_taxonomy' );
    28                 // check if taxonomy is generally enabled.
    29                 $is_enabled = empty( $taxonomy->show_in_rest ) ? false : true;
    30                 // check if taxonomy enabled in plugin settings.
    31                 $is_enabled_in_plugin = isset( $options[ $args['label_for'] ] ) && $options[ $args['label_for'] ] == 1 ? true : false;
    32                 $checked              = $is_enabled || $is_enabled_in_plugin ? 'checked' : '';
     27                $checked  = !empty( $taxonomy->show_in_rest ) ? 'checked' : '';
    3328                ?>
    3429                    <input type="checkbox"
Note: See TracChangeset for help on using the changeset viewer.