/** * fire on uninstall. delete options. * * @static */ public static function uninstall_hook() { foreach (CPTP_Util::get_post_types() as $post_type) { delete_option($post_type . '_structure'); } delete_option('no_taxonomy_structure'); }
/** * * Add hook flush_rules * @since 0.7.9 * */ public function update_rules() { $post_types = CPTP_Util::get_post_types(); foreach ($post_types as $post_type) { add_action('update_option_' . $post_type . '_structure', array(__CLASS__, 'queue_flush_rules'), 10, 2); } add_action('update_option_no_taxonomy_structure', array(__CLASS__, 'queue_flush_rules'), 10, 2); }
/** * * Add hook flush_rules * @since 0.7.9 * */ public function update_rules() { $post_types = CPTP_Util::get_post_types(); $type_count = count($post_types); $i = 0; foreach ($post_types as $post_type) { add_action('update_option_' . $post_type . '_structure', array($this, 'queue_flush_rules'), 10, 2); } add_action('update_option_no_taxonomy_structure', array($this, 'queue_flush_rules'), 10, 2); }
/** * * Setting Init * @since 0.7 * */ public function settings_api_init() { add_settings_section('cptp_setting_section', __('Permalink Setting for custom post type', 'cptp'), array($this, 'setting_section_callback_function'), 'permalink'); $post_types = CPTP_Util::get_post_types(); foreach ($post_types as $post_type) { add_settings_field($post_type . '_structure', $post_type, array($this, 'setting_structure_callback_function'), 'permalink', 'cptp_setting_section', array('label_for' => $post_type . '_structure', 'post_type' => $post_type)); register_setting('permalink', $post_type . '_structure'); } add_settings_field('no_taxonomy_structure', __('Use custom permalink of custom taxonomy archive.', 'cptp'), array($this, 'setting_no_tax_structure_callback_function'), 'permalink', 'cptp_setting_section', array('label_for' => 'no_taxonomy_structure')); register_setting('permalink', 'no_taxonomy_structure'); add_settings_field('add_post_type_for_tax', __('Add post_type query for custom taxonomy archive.', 'cptp'), array($this, 'add_post_type_for_tax_callback_function'), 'permalink', 'cptp_setting_section', array('label_for' => 'add_post_type_for_tax')); register_setting('permalink', 'no_taxonomy_structure'); }
/** * * Setting Init * @since 0.7 * */ public function settings_api_init() { add_settings_section('cptp_setting_section', __("Permalink Setting for custom post type", 'cptp'), array($this, 'setting_section_callback_function'), 'permalink'); $post_types = CPTP_Util::get_post_types(); foreach ($post_types as $post_type) { if (isset($_POST['submit']) and isset($_POST['_wp_http_referer'])) { if (strpos($_POST['_wp_http_referer'], 'options-permalink.php') !== FALSE) { $structure = trim(esc_attr($_POST[$post_type . '_structure'])); #get setting #default permalink structure if (!$structure) { $structure = CPTP_DEFAULT_PERMALINK; } $structure = str_replace('//', '/', '/' . $structure); # first "/" #last "/" $lastString = substr(trim(esc_attr($_POST['permalink_structure'])), -1); $structure = rtrim($structure, '/'); if ($lastString == '/') { $structure = $structure . '/'; } update_option($post_type . '_structure', $structure); } } add_settings_field($post_type . '_structure', $post_type, array($this, 'setting_structure_callback_function'), 'permalink', 'cptp_setting_section', $post_type . '_structure'); register_setting('permalink', $post_type . '_structure'); } add_settings_field('no_taxonomy_structure', __("Use custom permalink of custom taxonomy archive.", 'cptp'), array($this, 'setting_no_tax_structure_callback_function'), 'permalink', 'cptp_setting_section'); register_setting('permalink', 'no_taxonomy_structure'); if (isset($_POST['submit']) && isset($_POST['_wp_http_referer']) && strpos($_POST['_wp_http_referer'], 'options-permalink.php') !== false) { if (!isset($_POST['no_taxonomy_structure'])) { $set = true; } else { $set = false; } update_option('no_taxonomy_structure', $set); } }