Skip to content

Commit

Permalink
add wpml support setting ui
Browse files Browse the repository at this point in the history
  • Loading branch information
torounit committed Jul 20, 2020
1 parent 8358394 commit f22a07a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
23 changes: 22 additions & 1 deletion CPTP/Module/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,21 @@ public function settings_api_init() {
)
);

register_setting( 'permalink', 'no_taxonomy_structure' );
register_setting( 'permalink', 'add_post_type_for_tax' );


add_settings_field(
'cptp_wpml_support',
__( 'WPML Support (experimental)', 'custom-post-type-permalinks' ),
array( $this, 'cptp_wpml_support_callback_function' ),
'permalink',
'cptp_setting_section',
array(
'label_for' => 'cptp_wpml_support',
)
);

register_setting( 'permalink', 'cptp_wpml_support' );
}

/**
Expand Down Expand Up @@ -175,6 +189,13 @@ public function add_post_type_for_tax_callback_function() {
esc_html_e( 'There are cases when the template to be loaded is changed.', 'custom-post-type-permalinks' );
}

/**
* Show checkbox for post type query.
*/
public function cptp_wpml_support_callback_function() {
echo '<input name="cptp_wpml_support" id="cptp_wpml_support" type="checkbox" value="1" class="code" ' . checked( true, get_option( 'cptp_wpml_support' ), false ) . ' /> ';
esc_html_e( 'WPML Support.', 'custom-post-type-permalinks' );
}

/**
* Enqueue css and js
Expand Down
6 changes: 4 additions & 2 deletions CPTP/Module/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ public function save_options() {
endforeach;
$no_taxonomy_structure = ! filter_input( INPUT_POST, 'no_taxonomy_structure' );
$add_post_type_for_tax = filter_input( INPUT_POST, 'add_post_type_for_tax' );
$cptp_wpml_support = filter_input( INPUT_POST, 'cptp_wpml_support' );

update_option( 'no_taxonomy_structure', $no_taxonomy_structure );
update_option( 'add_post_type_for_tax', $add_post_type_for_tax );
update_option( 'no_taxonomy_structure', ! ! $no_taxonomy_structure );
update_option( 'add_post_type_for_tax', ! ! $add_post_type_for_tax );
update_option( 'cptp_wpml_support', ! ! $cptp_wpml_support );
update_option( 'cptp_permalink_checked', CPTP_VERSION );
}

Expand Down

0 comments on commit f22a07a

Please sign in to comment.