/**
  * Loading Scripts and Styles for current Field
  *
  * @return void
  */
 static function admin_enqueue_scripts()
 {
     wp_enqueue_style('field-wpp-taxonomy-inherited', ud_get_wpp_terms()->path('static/styles/fields/wpp-taxonomy-inherited.css'), array('wp-admin'), ud_get_wpp_terms('version'));
 }
Пример #2
0
        /**
         * Extend WP-Property settings:
         * - Extend Property Search with Taxonomies
         * - Adds Taxonomies to groups
         *
         */
        public function extend_wpp_settings()
        {
            global $wp_properties;
            /** STEP 1. Add taxonomies to searchable attributes */
            $taxonomies = $this->get('config.taxonomies', array());
            if (!isset($wp_properties['searchable_attributes']) || !is_array($wp_properties['searchable_attributes'])) {
                $wp_properties['searchable_attributes'] = array();
            }
            foreach ($taxonomies as $taxonomy => $data) {
                if (isset($data['public']) && $data['public']) {
                    array_push($wp_properties['searchable_attributes'], $taxonomy);
                }
            }
            ud_get_wp_property()->set('searchable_attributes', $wp_properties['searchable_attributes']);
            /** STEP 2. Add taxonomies to property stats groups */
            $groups = $this->get('config.groups', array());
            if (!isset($wp_properties['property_stats_groups']) || !is_array($wp_properties['property_stats_groups'])) {
                $wp_properties['property_stats_groups'] = array();
            }
            $wp_properties['property_stats_groups'] = array_merge($wp_properties['property_stats_groups'], $groups);
            ud_get_wp_property()->set('property_stats_groups', $wp_properties['property_stats_groups']);
            /** STEP 3. Extend Property Search form */
            add_filter('wpp::show_search_field_with_no_values', function ($bool, $slug) {
                $taxonomies = ud_get_wpp_terms('config.taxonomies', array());
                if (array_key_exists($slug, $taxonomies)) {
                    return true;
                }
                return $bool;
            }, 10, 2);
            /** Take care about Taxonomies fields */
            foreach ($taxonomies as $taxonomy => $data) {
                add_filter('wpp_search_form_field_' . $taxonomy, function ($html, $taxonomy, $label, $value, $input, $random_id) {
                    $search_input = ud_get_wp_property("searchable_attr_fields.{$taxonomy}");
                    $terms = get_terms($taxonomy, array('fields' => 'id=>name'));
                    ob_start();
                    switch ($search_input) {
                        case 'multi_checkbox':
                            ?>
                <ul class="wpp_multi_checkbox taxonomy <?php 
                            echo $taxonomy;
                            ?>
">
                  <?php 
                            foreach ($terms as $term_id => $label) {
                                ?>
                    <?php 
                                $unique_id = rand(10000, 99999);
                                ?>
                    <li>
                      <input name="wpp_search[<?php 
                                echo $taxonomy;
                                ?>
][]" <?php 
                                echo is_array($value) && in_array($term_id, $value) ? 'checked="true"' : '';
                                ?>
 id="wpp_attribute_checkbox_<?php 
                                echo $unique_id;
                                ?>
" type="checkbox" value="<?php 
                                echo $term_id;
                                ?>
"/>
                      <label for="wpp_attribute_checkbox_<?php 
                                echo $unique_id;
                                ?>
" class="wpp_search_label_second_level"><?php 
                                echo $label;
                                ?>
</label>
                    </li>
                  <?php 
                            }
                            ?>
                </ul>
                <?php 
                            break;
                        case 'dropdown':
                        default:
                            ?>
                <select id="<?php 
                            echo $random_id;
                            ?>
" class="wpp_search_select_field taxonomy <?php 
                            echo $taxonomy;
                            ?>
" name="wpp_search[<?php 
                            echo $taxonomy;
                            ?>
]">
                  <option value="-1"><?php 
                            _e('Any', ud_get_wpp_terms('domain'));
                            ?>
</option>
                  <?php 
                            foreach ($terms as $term_id => $label) {
                                ?>
                    <option value="<?php 
                                echo $term_id;
                                ?>
" <?php 
                                selected($value, $term_id);
                                ?>
><?php 
                                echo $label;
                                ?>
</option>
                  <?php 
                            }
                            ?>
                </select>
                <?php 
                            break;
                    }
                    return ob_get_clean();
                }, 10, 6);
            }
        }
Пример #3
0
            if (!class_exists('\\UsabilityDynamics\\WPP\\Terms_Bootstrap')) {
                throw new Exception(__('Distributive is broken. Plugin loader is not available. Try to remove and upload plugin again.', 'wpp_terms'));
            }
        } catch (Exception $e) {
            $_ud_wpp_terms_error = $e->getMessage();
            return false;
        }
        return true;
    }
}
if (!function_exists('ud_wpp_terms_message')) {
    /**
     * Renders admin notes in case there are errors on plugin init
     *
     * @author Usability Dynamics, Inc.
     * @since 1.0.0
     */
    function ud_wpp_terms_message()
    {
        global $_ud_wpp_terms_error;
        if (!empty($_ud_wpp_terms_error)) {
            $message = sprintf(__('<p><b>%s</b> can not be initialized. %s</p>', 'wpp_terms'), 'Wp-Property Terms', $_ud_wpp_terms_error);
            echo '<div class="error fade" style="padding:11px;">' . $message . '</div>';
        }
    }
    add_action('admin_notices', 'ud_wpp_terms_message');
}
if (ud_check_wpp_terms()) {
    //** Initialize. */
    ud_get_wpp_terms();
}
Пример #4
0
<li class="wpp_development_advanced_option">
  <input id="<?php 
    echo $property_slug . "_" . $k;
    ?>
_taxonomy_hidden" <?php 
    if (isset($hidden[$property_slug]) && in_array($k, $hidden[$property_slug])) {
        echo " checked ";
    }
    ?>
 type="checkbox" name="wpp_terms[hidden][<?php 
    echo $property_slug;
    ?>
][]" value="<?php 
    echo $k;
    ?>
"/>
  <label for="<?php 
    echo $property_slug . "_" . $k;
    ?>
_taxonomy_hidden">
    <?php 
    echo $data['label'];
    ?>
 (<?php 
    _e('taxonomy', ud_get_wpp_terms('domain'));
    ?>
)
  </label>
</li>
<?php 
}
 data-desc="<?php 
        echo $type['desc'];
        ?>
" ><?php 
        echo $type['label'];
        ?>
</option>
          <?php 
    }
    ?>
        </select>
      </td>

      <td>
        <span class="wpp_delete_row wpp_link"><?php 
    _e('Delete', ud_get_wpp_terms()->domain);
    ?>
</span>
      </td>
    </tr>

  <?php 
}
?>
  </tbody>

  <tfoot>
  <tr>
    <td colspan='4'>
      <input type="button" class="wpp_add_row button-secondary" value="<?php 
_e('Add Row', 'wpp');