Plugin Directory

Changeset 2215006


Ignore:
Timestamp:
12/19/2019 11:15:32 AM (6 years ago)
Author:
b3none
Message:

Remove settings page and release 1.3.0

Location:
the-insertr
Files:
4 added
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • the-insertr/trunk/the-insertr.php

    r2211669 r2215006  
    66 * Description: Wordpress dynamic keyword insertion plugin.
    77 * Author: Herdl
    8  * Version: 1.2.0
     8 * Version: 1.3.0
    99 * Author URI: https://herdl.com
    1010 */
     
    1212if (!defined('WPINC')) {
    1313    die('No direct access allowed');
    14 }
    15 
    16 function theinsertr_register_settings() {
    17     add_submenu_page('options-general.php', 'TheInsertr', 'TheInsertr', 'manage_options', 'theinsertr', 'theinsertr_settings');
    18 }
    19 
    20 function theinsertr_settings() {
    21     if (!current_user_can('administrator')) {
    22         echo '<p>Sorry, you are not allowed to access this page.</p>';
    23         return;
    24     }
    25 
    26     if (isset($_REQUEST['submit'])) {
    27         if (!isset($_REQUEST['theinsertr_nonce'])) {
    28             $errorMessage = 'nonce field is missing. Settings NOT saved.';
    29         } elseif (!wp_verify_nonce($_REQUEST['theinsertr_nonce'], 'theinsertr')) {
    30             $errorMessage = 'Invalid nonce specified. Settings NOT saved.';
    31         } else {
    32             update_option('theinsertr_acf_enable', isset($_REQUEST['theinsertr_acf_enable']) ? 'yes' : 'no');
    33             update_option('theinsertr_yoast_title_enable', isset($_REQUEST['theinsertr_yoast_title_enable']) ? 'yes' : 'no');
    34 
    35             $message = 'Settings Saved.';
    36         }
    37     }
    38 
    39     include_once(__DIR__ . '/templates/settings.php');
    40 }
    41 
    42 if (get_option('theinsertr_acf_enable') === 'yes') {
    43     add_filter('acf/format_value', 'my_acf_format_value');
    44 
    45     function my_acf_format_value($value, $post_id, $field) {
    46         if (!is_array($value)) {
    47             $value = do_shortcode($value);
    48         }
    49 
    50         return $value;
    51     }
    52 }
    53 
    54 if (get_option('theinsertr_yoast_title_enable') === 'yes') {
    55     add_filter('wpseo_title', 'my_wpseo_title');
    56 
    57     function my_wpseo_title($title) {
    58         return do_shortcode($title);
    59     }
    6014}
    6115
     
    7832}
    7933
    80 add_action('admin_menu', 'theinsertr_register_settings');
    81 add_action('wp_footer', 'theinsertr_render_script');
    8234add_shortcode('insertr', 'insertr_function');
Note: See TracChangeset for help on using the changeset viewer.