Admin.php
8 years ago
FlushRules.php
8 years ago
GetArchives.php
8 years ago
Option.php
8 years ago
Permalink.php
8 years ago
Rewrite.php
7 years ago
Setting.php
8 years ago
Setting.php
69 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Management Setting. |
| 4 | * |
| 5 | * @package Custom_Post_Type_Permalinks |
| 6 | */ |
| 7 | |
| 8 | /** |
| 9 | * For load plugin. |
| 10 | * |
| 11 | * @since 0.9.4 |
| 12 | * */ |
| 13 | class CPTP_Module_Setting extends CPTP_Module { |
| 14 | |
| 15 | /** |
| 16 | * Module hooks. |
| 17 | */ |
| 18 | public function add_hook() { |
| 19 | $this->update_version(); |
| 20 | add_action( 'init', array( $this, 'load_textdomain' ) ); |
| 21 | add_action( 'upgrader_process_complete', array( $this, 'upgrader_process_complete' ), 10, 2 ); |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Save CPTP version. |
| 26 | * |
| 27 | * @since 0.8.6 |
| 28 | */ |
| 29 | public function update_version() { |
| 30 | update_option( 'cptp_version', CPTP_VERSION ); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * After update complete. |
| 35 | * |
| 36 | * @since 3.0.0 |
| 37 | * |
| 38 | * @param object $wp_upgrader WP_Upgrader instance. |
| 39 | * @param array $options Extra information about performed upgrade. |
| 40 | */ |
| 41 | public function upgrader_process_complete( $wp_upgrader, $options ) { |
| 42 | |
| 43 | if ( empty( $options['plugins'] ) ) { |
| 44 | return; |
| 45 | } |
| 46 | |
| 47 | if ( ! is_array( $options['plugins'] ) ) { |
| 48 | return; |
| 49 | } |
| 50 | |
| 51 | if ( 'update' === $options['action'] && 'plugin' === $options['type'] ) { |
| 52 | $plugin_path = plugin_basename( CPTP_PLUGIN_FILE ); |
| 53 | if ( in_array( $plugin_path, $options['plugins'], true ) ) { |
| 54 | // for update code. |
| 55 | add_option( 'no_taxonomy_structure', false ); |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Load textdomain |
| 62 | * |
| 63 | * @since 0.6.2 |
| 64 | */ |
| 65 | public function load_textdomain() { |
| 66 | load_plugin_textdomain( 'custom-post-type-permalinks', false, 'custom-post-type-permalinks/language' ); |
| 67 | } |
| 68 | } |
| 69 |