Skip to content

Commit

Permalink
add option for set post types to load jeomap assets
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusgimenez committed Sep 8, 2021
1 parent 97af41e commit 03e2a4c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/includes/settings/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public function get_option( $option_name ) {
if (!$options) {
$options = [];
}
if( isset( $options[ 'enabled_post_types'] ) && ! empty( $options[ 'enabled_post_types'] ) ) {
if ( ! is_array( $options[ 'enabled_post_types'] ) ) {
$options[ 'enabled_post_types'] = explode( ',', trim( esc_textarea( $options[ 'enabled_post_types'] ) ) );
}
}
$options = array_merge($this->default_options, $options);
if ( isset($options[$option_name]) ) {
return $options[$option_name];
Expand Down
7 changes: 7 additions & 0 deletions src/includes/settings/settings-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@
</td>
</tr>

<tr>
<th scope="row"><label for="enabled_post_types"><?php _e('Enabled Post Types. Default: post,storymap', 'jeo'); ?></label></th>
<td>
<input name="<?php echo esc_html( $this->get_field_name('enabled_post_types') ); ?>" placeholder="<?= __("Post types separated by comma, Ex: map,post,page ", "jeo") ?>" type="text" id="enabled_post_types" value="<?php echo esc_textarea( implode( ',' , $this->get_option('enabled_post_types') ) ); ?>" class="regular-text">
</td>
</tr>

<tr>
<th scope="row"><h2 style="padding: 0; margin: 0"><?php _e('API', 'jeo'); ?></h2></th>
<td>
Expand Down
2 changes: 1 addition & 1 deletion src/includes/traits/class-singleton.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function should_load_assets() {
$should_load_assets = true;
}

return $should_load_assets;
return apply_filters( 'jeo_should_load_assets' , $should_load_assets );
}

final public static function get_instance() {
Expand Down

0 comments on commit 03e2a4c

Please sign in to comment.