wp/wp-content/plugins/option-tree/includes/ot-functions-settings-page.php
changeset 11 bf1778c34b9a
parent 5 5e2f62d02dcd
equal deleted inserted replaced
10:372f2766ea20 11:bf1778c34b9a
     1 <?php if ( ! defined( 'OT_VERSION' ) ) exit( 'No direct script access allowed' );
     1 <?php
     2 /**
     2 /**
     3  * OptionTree settings page functions.
     3  * OptionTree Settings Page Functions.
     4  *
     4  *
     5  * @package   OptionTree
     5  * @package OptionTree
     6  * @author    Derek Herman <derek@valendesigns.com>
       
     7  * @copyright Copyright (c) 2013, Derek Herman
       
     8  * @since     2.0
       
     9  */
     6  */
    10 
     7 
    11 /**
     8 if ( ! defined( 'OT_VERSION' ) ) {
    12  * Create option type.
     9 	exit( 'No direct script access allowed' );
    13  *
    10 }
    14  * @return    string
    11 
    15  *
       
    16  * @access    public
       
    17  * @since     2.0
       
    18  */
       
    19 if ( ! function_exists( 'ot_type_theme_options_ui' ) ) {
    12 if ( ! function_exists( 'ot_type_theme_options_ui' ) ) {
    20   
    13 
    21   function ot_type_theme_options_ui() {
    14 	/**
    22     global $blog_id;
    15 	 * Create option type.
    23     
    16 	 *
    24     echo '<form method="post" id="option-tree-settings-form">';
    17 	 * @access public
    25       
    18 	 * @since  2.0
    26       /* form nonce */
    19 	 */
    27       wp_nonce_field( 'option_tree_settings_form', 'option_tree_settings_nonce' );
    20 	function ot_type_theme_options_ui() {
    28       
    21 		global $blog_id;
    29       /* format setting outer wrapper */
    22 
    30       echo '<div class="format-setting type-textblock has-desc">';
    23 		echo '<form method="post" id="option-tree-settings-form">';
    31         
    24 
    32         /* description */
    25 		// Form nonce.
    33         echo '<div class="description">';
    26 		wp_nonce_field( 'option_tree_settings_form', 'option_tree_settings_nonce' );
    34           
    27 
    35           echo '<h4>'. __( 'Warning!', 'option-tree' ) . '</h4>';
    28 		// Format setting outer wrapper.
    36           echo '<p class="warning">' . sprintf( __( 'Go to the %s page if you want to save data, this page is for adding settings.', 'option-tree' ), '<a href="' . get_admin_url( $blog_id, apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ) . '?page=' . apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) ) . '"><code>Appearance->Theme Options</code></a>' ) . '</p>';
    29 		echo '<div class="format-setting type-textblock has-desc">';
    37           echo '<p class="warning">' . sprintf( __( 'If you\'re unsure or not completely positive that you should be editing these settings, you should read the %s first.', 'option-tree' ), '<a href="' . get_admin_url( $blog_id, 'admin.php?page=ot-documentation' ) . '"><code>OptionTree->Documentation</code></a>' ) . '</p>';
    30 
    38           echo '<h4>'. __( 'Things could break or be improperly displayed to the end-user if you do one of the following:', 'option-tree' ) . '</h4>';
    31 		// Description.
    39           echo '<p class="warning">' . __( 'Give two sections the same ID, give two settings the same ID, give two contextual help content areas the same ID, don\'t create any settings, or have a section at the end of the settings list.', 'option-tree' ) . '</p>';
    32 		echo '<div class="description">';
    40           echo '<p>' . __( 'You can create as many settings as your project requires and use them how you see fit. When you add a setting here, it will be available on the Theme Options page for use in your theme. To separate your settings into sections, click the "Add Section" button, fill in the input fields, and a new navigation menu item will be created.', 'option-tree' ) . '</p>';
    33 
    41           echo '<p>' . __( 'All of the settings can be sorted and rearranged to your liking with Drag & Drop. Don\'t worry about the order in which you create your settings, you can always reorder them.', 'option-tree' ) . '</p>';
    34 		echo '<h4>' . esc_html__( 'Warning!', 'option-tree' ) . '</h4>';
    42           
    35 
    43         echo '</div>';
    36 		/* translators: %s: link to theme options */
    44         
    37 		$string = esc_html__( 'Go to the %s page if you want to save data, this page is for adding settings.', 'option-tree' );
    45         /* get the saved settings */
    38 		echo '<p class="warning">' . sprintf( $string, '<a href="' . esc_url_raw( get_admin_url( $blog_id, apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ) ) . '?page=' . apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) ) . '"><code>' . esc_html__( 'Appearance->Theme Options', 'option-tree' ) . '</code></a>' ) . '</p>'; // phpcs:ignore
    46         $settings = get_option( ot_settings_id() );
    39 
    47 
    40 		/* translators: %s: link to documentation */
    48         /* wrap settings array */
    41 		$string = esc_html__( 'If you\'re unsure or not completely positive that you should be editing these settings, you should read the %s first.', 'option-tree' );
    49         echo '<div class="format-setting-inner">';
    42 		echo '<p class="warning">' . sprintf( $string, '<a href="' . esc_url_raw( get_admin_url( $blog_id, 'admin.php?page=ot-documentation' ) ) . '"><code>' . esc_html__( 'OptionTree->Documentation', 'option-tree' ) . '</code></a>' ) . '</p>'; // phpcs:ignore
    50           
    43 
    51           /* set count to zero */
    44 		echo '<h4>' . esc_html__( 'Things could break or be improperly displayed to the end-user if you do one of the following:', 'option-tree' ) . '</h4>';
    52           $count = 0;
    45 		echo '<p class="warning">' . esc_html__( 'Give two sections the same ID, give two settings the same ID, give two contextual help content areas the same ID, don\'t create any settings, or have a section at the end of the settings list.', 'option-tree' ) . '</p>';
    53   
    46 		echo '<p>' . esc_html__( 'You can create as many settings as your project requires and use them how you see fit. When you add a setting here, it will be available on the Theme Options page for use in your theme. To separate your settings into sections, click the "Add Section" button, fill in the input fields, and a new navigation menu item will be created.', 'option-tree' ) . '</p>';
    54           /* loop through each section and its settings */
    47 		echo '<p>' . esc_html__( 'All of the settings can be sorted and rearranged to your liking with Drag & Drop. Don\'t worry about the order in which you create your settings, you can always reorder them.', 'option-tree' ) . '</p>';
    55           echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_settings_list" data-name="' . ot_settings_id() . '[settings]">';
    48 
    56           
    49 		echo '</div>';
    57           if ( isset( $settings['sections'] ) ) {
    50 
    58           
    51 		// Get the saved settings.
    59             foreach( $settings['sections'] as $section ) {
    52 		$settings = get_option( ot_settings_id() );
    60               
    53 
    61               /* section */
    54 		// Wrap settings array.
    62               echo '<li class="' . ( $count == 0 ? 'ui-state-disabled' : 'ui-state-default' ) . ' list-section">' . ot_sections_view( ot_settings_id() . '[sections]', $count, $section ) . '</li>';
    55 		echo '<div class="format-setting-inner">';
    63               
    56 
    64               /* increment item count */
    57 		// Set count to zero.
    65               $count++;
    58 		$count = 0;
    66               
    59 
    67               /* settings in this section */
    60 		// Loop through each section and its settings.
    68               if ( isset( $settings['settings'] ) ) {
    61 		echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_settings_list" data-name="' . esc_attr( ot_settings_id() ) . '[settings]">';
    69                 
    62 
    70                 foreach( $settings['settings'] as $setting ) {
    63 		if ( isset( $settings['sections'] ) ) {
    71                   
    64 
    72                   if ( isset( $setting['section'] ) && $setting['section'] == $section['id'] ) {
    65 			foreach ( $settings['sections'] as $section ) {
    73                     
    66 
    74                     echo '<li class="ui-state-default list-setting">' . ot_settings_view( ot_settings_id() . '[settings]', $count, $setting ) . '</li>';
    67 				// Section.
    75                     
    68 				echo '<li class="' . ( $count == 0 ? 'ui-state-disabled' : 'ui-state-default' ) . ' list-section">' . ot_sections_view( ot_settings_id() . '[sections]', $count, $section ) . '</li>'; // phpcs:ignore
    76                     /* increment item count */
    69 
    77                     $count++;
    70 				// Increment item count.
    78                     
    71 				$count++;
    79                   }
    72 
    80                   
    73 				// Settings in this section.
    81                 }
    74 				if ( isset( $settings['settings'] ) ) {
    82                 
    75 
    83               }
    76 					foreach ( $settings['settings'] as $setting ) {
    84 
    77 
    85             }
    78 						if ( isset( $setting['section'] ) && $setting['section'] === $section['id'] ) {
    86             
    79 
    87           }
    80 							echo '<li class="ui-state-default list-setting">' . ot_settings_view( ot_settings_id() . '[settings]', $count, $setting ) . '</li>'; // phpcs:ignore
    88           
    81 
    89           echo '</ul>';
    82 							// Increment item count.
    90           
    83 							$count++;
    91           /* buttons */
    84 						}
    92           echo '<a href="javascript:void(0);" class="option-tree-section-add option-tree-ui-button button hug-left">' . __( 'Add Section', 'option-tree' ) . '</a>';
    85 					}
    93           echo '<a href="javascript:void(0);" class="option-tree-setting-add option-tree-ui-button button">' . __( 'Add Setting', 'option-tree' ) . '</a>';
    86 				}
    94           echo '<button class="option-tree-ui-button button button-primary right hug-right">' . __( 'Save Changes', 'option-tree' ) . '</button>';
    87 			}
    95           
    88 		}
    96           /* sidebar textarea */
    89 
    97           echo '
    90 		echo '</ul>';
    98           <div class="format-setting-label" id="contextual-help-label">
    91 
    99             <h3 class="label">' . __( 'Contextual Help', 'option-tree' ) . '</h3>
    92 		// Buttons.
   100           </div>
    93 		echo '<a href="javascript:void(0);" class="option-tree-section-add option-tree-ui-button button hug-left">' . esc_html__( 'Add Section', 'option-tree' ) . '</a>';
   101           <div class="format-settings" id="contextual-help-setting">
    94 		echo '<a href="javascript:void(0);" class="option-tree-setting-add option-tree-ui-button button">' . esc_html__( 'Add Setting', 'option-tree' ) . '</a>';
   102             <div class="format-setting type-textarea no-desc">
    95 		echo '<button class="option-tree-ui-button button button-primary right hug-right">' . esc_html__( 'Save Changes', 'option-tree' ) . '</button>';
   103               <div class="description"><strong>' . __( 'Contextual Help Sidebar', 'option-tree' ) . '</strong>: ' . __( 'If you decide to add contextual help to the Theme Option page, enter the optional "Sidebar" HTML here. This would be an extremely useful place to add links to your themes documentation or support forum. Only after you\'ve added some content below will this display to the user.', 'option-tree' ) . '</div>
    96 
   104               <div class="format-setting-inner">
    97 		// Sidebar textarea.
   105                 <textarea class="textarea" rows="10" cols="40" name="' . ot_settings_id(). '[contextual_help][sidebar]">' . ( isset( $settings['contextual_help']['sidebar'] ) ? esc_html( $settings['contextual_help']['sidebar'] ) : '' ) . '</textarea>
    98 		echo '
   106               </div>
    99 		<div class="format-setting-label" id="contextual-help-label">
   107             </div>
   100 			<h3 class="label">' . esc_html__( 'Contextual Help', 'option-tree' ) . '</h3>
   108           </div>';
   101 		</div>
   109           
   102 		<div class="format-settings" id="contextual-help-setting">
   110           /* set count to zero */
   103 			<div class="format-setting type-textarea no-desc">
   111           $count = 0;
   104 				<div class="description"><strong>' . esc_html__( 'Contextual Help Sidebar', 'option-tree' ) . '</strong>: ' . esc_html__( 'If you decide to add contextual help to the Theme Option page, enter the optional "Sidebar" HTML here. This would be an extremely useful place to add links to your themes documentation or support forum. Only after you\'ve added some content below will this display to the user.', 'option-tree' ) . '</div>
   112           
   105 				<div class="format-setting-inner">
   113           /* loop through each contextual_help content section */
   106 					<textarea class="textarea" rows="10" cols="40" name="' . esc_attr( ot_settings_id() ) . '[contextual_help][sidebar]">' . ( isset( $settings['contextual_help']['sidebar'] ) ? esc_html( $settings['contextual_help']['sidebar'] ) : '' ) . '</textarea>
   114           echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_settings_help" data-name="' . ot_settings_id(). '[contextual_help][content]">';
   107 				</div>
   115           
   108 			</div>
   116           if ( isset( $settings['contextual_help']['content'] ) ) {
   109 		</div>';
   117           
   110 
   118             foreach( $settings['contextual_help']['content'] as $content ) {
   111 		// Set count to zero.
   119               
   112 		$count = 0;
   120               /* content */
   113 
   121               echo '<li class="ui-state-default list-contextual-help">' . ot_contextual_help_view( ot_settings_id() . '[contextual_help][content]',  $count, $content ) . '</li>';
   114 		// Loop through each contextual_help content section.
   122               
   115 		echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_settings_help" data-name="' . esc_attr( ot_settings_id() ) . '[contextual_help][content]">';
   123               /* increment content count */
   116 
   124               $count++;
   117 		if ( isset( $settings['contextual_help']['content'] ) ) {
   125 
   118 
   126             }
   119 			foreach ( $settings['contextual_help']['content'] as $content ) {
   127             
   120 
   128           }
   121 				// Content.
   129           
   122 				echo '<li class="ui-state-default list-contextual-help">' . ot_contextual_help_view( ot_settings_id() . '[contextual_help][content]', $count, $content ) . '</li>'; // phpcs:ignore
   130           echo '</ul>';
   123 
   131 
   124 				// Increment content count.
   132           echo '<a href="javascript:void(0);" class="option-tree-help-add option-tree-ui-button button hug-left">' . __( 'Add Contextual Help Content', 'option-tree' ) . '</a>';
   125 				$count++;
   133           echo '<button class="option-tree-ui-button button button-primary right hug-right">' . __( 'Save Changes', 'option-tree' ) . '</button>';
   126 			}
   134 
   127 		}
   135         echo '</div>';
   128 
   136         
   129 		echo '</ul>';
   137       echo '</div>';
   130 
   138     
   131 		echo '<a href="javascript:void(0);" class="option-tree-help-add option-tree-ui-button button hug-left">' . esc_html__( 'Add Contextual Help Content', 'option-tree' ) . '</a>';
   139     echo '</form>';
   132 		echo '<button class="option-tree-ui-button button button-primary right hug-right">' . esc_html__( 'Save Changes', 'option-tree' ) . '</button>';
   140     
   133 
   141   }
   134 		echo '</div>';
   142   
   135 
   143 }
   136 		echo '</div>';
   144 
   137 
   145 /**
   138 		echo '</form>';
   146  * Import XML option type.
   139 	}
   147  *
   140 }
   148  * @return    string
   141 
   149  *
       
   150  * @access    public
       
   151  * @since     2.0
       
   152  */
       
   153 if ( ! function_exists( 'ot_type_import_xml' ) ) {
       
   154   
       
   155   function ot_type_import_xml() {
       
   156     
       
   157     echo '<form method="post" id="import-xml-form">';
       
   158       
       
   159       /* form nonce */
       
   160       wp_nonce_field( 'import_xml_form', 'import_xml_nonce' );
       
   161       
       
   162       /* format setting outer wrapper */
       
   163       echo '<div class="format-setting type-textblock has-desc">';
       
   164         
       
   165         /* description */
       
   166         echo '<div class="description">';
       
   167           
       
   168           echo '<p class="deprecated">' . __( 'This import method has been deprecated. That means it has been replaced by a new method and is no longer supported, and may be removed from future versions. All themes that use this import method should be converted to use its replacement below.', 'option-tree' ) . '</p>';
       
   169           
       
   170           echo '<p>' . sprintf( __( 'If you were given a Theme Options XML file with a premium or free theme, locate it on your hard drive and upload that file by clicking the upload button. A popup window will appear, upload the XML file and click "%s". The file URL should be in the upload input, if it is click "Import XML".', 'option-tree' ), apply_filters( 'ot_upload_text', __( 'Send to OptionTree', 'option-tree' ) ) ) . '</p>';
       
   171           
       
   172           /* button */
       
   173           echo '<button class="option-tree-ui-button button button-primary right hug-right">' . __( 'Import XML', 'option-tree' ) . '</button>';
       
   174           
       
   175         echo '</div>';
       
   176         
       
   177         echo '<div class="format-setting-inner">';
       
   178           
       
   179           /* build upload */
       
   180           echo '<div class="option-tree-ui-upload-parent">';
       
   181             
       
   182             /* input */
       
   183             echo '<input type="text" name="import_xml" id="import_xml" value="" class="widefat option-tree-ui-upload-input" />';
       
   184             
       
   185             /* get media post_id */
       
   186             $post_id = ( $id = ot_get_media_post_ID() ) ? (int) $id : 0;
       
   187           
       
   188             /* add xml button */
       
   189             echo '<a href="javascript:void(0);" class="ot_upload_media option-tree-ui-button button button-primary light" rel="' . $post_id . '" title="' . __( 'Add XML', 'option-tree' ) . '"><span class="icon ot-icon-plus-circle"></span>' . __( 'Add XML', 'option-tree' ) . '</a>';
       
   190           
       
   191           echo '</div>';
       
   192           
       
   193         echo '</div>';
       
   194         
       
   195       echo '</div>';
       
   196       
       
   197     echo '</form>';
       
   198     
       
   199   }
       
   200   
       
   201 }
       
   202 
       
   203 /**
       
   204  * Import Settings option type.
       
   205  *
       
   206  * @return    string
       
   207  *
       
   208  * @access    public
       
   209  * @since     2.0
       
   210  */
       
   211 if ( ! function_exists( 'ot_type_import_settings' ) ) {
   142 if ( ! function_exists( 'ot_type_import_settings' ) ) {
   212   
   143 
   213   function ot_type_import_settings() {
   144 	/**
   214     
   145 	 * Import Settings option type.
   215     echo '<form method="post" id="import-settings-form">';
   146 	 *
   216       
   147 	 * @access public
   217       /* form nonce */
   148 	 * @since  2.0
   218       wp_nonce_field( 'import_settings_form', 'import_settings_nonce' );
   149 	 */
   219       
   150 	function ot_type_import_settings() {
   220       /* format setting outer wrapper */
   151 
   221       echo '<div class="format-setting type-textarea has-desc">';
   152 		echo '<form method="post" id="import-settings-form">';
   222            
   153 
   223         /* description */
   154 		// Form nonce.
   224         echo '<div class="description">';
   155 		wp_nonce_field( 'import_settings_form', 'import_settings_nonce' );
   225           
   156 
   226           echo '<p>' . __( 'To import your Settings copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Settings" button.', 'option-tree' ) . '</p>';
   157 		// Format setting outer wrapper.
   227           
   158 		echo '<div class="format-setting type-textarea has-desc">';
   228           /* button */
   159 
   229           echo '<button class="option-tree-ui-button button button-primary right hug-right">' . __( 'Import Settings', 'option-tree' ) . '</button>';
   160 		// Description.
   230           
   161 		echo '<div class="description">';
   231         echo '</div>';
   162 
   232         
   163 		echo '<p>' . esc_html__( 'To import your Settings copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Settings" button.', 'option-tree' ) . '</p>';
   233         /* textarea */
   164 
   234         echo '<div class="format-setting-inner">';
   165 		echo '<button class="option-tree-ui-button button button-primary right hug-right">' . esc_html__( 'Import Settings', 'option-tree' ) . '</button>';
   235           
   166 
   236           echo '<textarea rows="10" cols="40" name="import_settings" id="import_settings" class="textarea"></textarea>';
   167 		echo '</div>';
   237 
   168 
   238         echo '</div>';
   169 		echo '<div class="format-setting-inner">';
   239         
   170 
   240       echo '</div>';
   171 		echo '<textarea rows="10" cols="40" name="import_settings" id="import_settings" class="textarea"></textarea>';
   241     
   172 
   242     echo '</form>';
   173 		echo '</div>';
   243     
   174 
   244   }
   175 		echo '</div>';
   245   
   176 
   246 }
   177 		echo '</form>';
   247 
   178 
   248 /**
   179 	}
   249  * Import Data option type.
   180 }
   250  *
   181 
   251  * @return    string
       
   252  *
       
   253  * @access    public
       
   254  * @since     2.0
       
   255  */
       
   256 if ( ! function_exists( 'ot_type_import_data' ) ) {
   182 if ( ! function_exists( 'ot_type_import_data' ) ) {
   257   
   183 
   258   function ot_type_import_data() {
   184 	/**
   259     
   185 	 * Import Data option type.
   260     echo '<form method="post" id="import-data-form">';
   186 	 *
   261       
   187 	 * @access public
   262       /* form nonce */
   188 	 * @since  2.0
   263       wp_nonce_field( 'import_data_form', 'import_data_nonce' );
   189 	 */
   264         
   190 	function ot_type_import_data() {
   265       /* format setting outer wrapper */
   191 
   266       echo '<div class="format-setting type-textarea has-desc">';
   192 		echo '<form method="post" id="import-data-form">';
   267         
   193 
   268         /* description */
   194 		// Form nonce.
   269         echo '<div class="description">';
   195 		wp_nonce_field( 'import_data_form', 'import_data_nonce' );
   270           
   196 
   271           if ( OT_SHOW_SETTINGS_IMPORT ) echo '<p>' . __( 'Only after you\'ve imported the Settings should you try and update your Theme Options.', 'option-tree' ) . '</p>';
   197 		// Format setting outer wrapper.
   272           
   198 		echo '<div class="format-setting type-textarea has-desc">';
   273           echo '<p>' . __( 'To import your Theme Options copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Theme Options" button.', 'option-tree' ) . '</p>';
   199 
   274           
   200 		// Description.
   275           /* button */
   201 		echo '<div class="description">';
   276           echo '<button class="option-tree-ui-button button button-primary right hug-right">' . __( 'Import Theme Options', 'option-tree' ) . '</button>';
   202 
   277           
   203 		if ( OT_SHOW_SETTINGS_IMPORT ) {
   278         echo '</div>';
   204 			echo '<p>' . esc_html__( 'Only after you\'ve imported the Settings should you try and update your Theme Options.', 'option-tree' ) . '</p>';
   279         
   205 		}
   280         /* textarea */
   206 
   281         echo '<div class="format-setting-inner">';
   207 		echo '<p>' . esc_html__( 'To import your Theme Options copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Theme Options" button.', 'option-tree' ) . '</p>';
   282           
   208 
   283           echo '<textarea rows="10" cols="40" name="import_data" id="import_data" class="textarea"></textarea>';
   209 		echo '<button class="option-tree-ui-button button button-primary right hug-right">' . esc_html__( 'Import Theme Options', 'option-tree' ) . '</button>';
   284 
   210 
   285         echo '</div>';
   211 		echo '</div>';
   286         
   212 
   287       echo '</div>';
   213 		echo '<div class="format-setting-inner">';
   288     
   214 
   289     echo '</form>';
   215 		echo '<textarea rows="10" cols="40" name="import_data" id="import_data" class="textarea"></textarea>';
   290     
   216 
   291   }
   217 		echo '</div>';
   292   
   218 
   293 }
   219 		echo '</div>';
   294 
   220 
   295 /**
   221 		echo '</form>';
   296  * Import Layouts option type.
   222 	}
   297  *
   223 }
   298  * @return    string
   224 
   299  *
       
   300  * @access    public
       
   301  * @since     2.0
       
   302  */
       
   303 if ( ! function_exists( 'ot_type_import_layouts' ) ) {
   225 if ( ! function_exists( 'ot_type_import_layouts' ) ) {
   304   
   226 
   305   function ot_type_import_layouts() {
   227 	/**
   306     
   228 	 * Import Layouts option type.
   307     echo '<form method="post" id="import-layouts-form">';
   229 	 *
   308       
   230 	 * @access public
   309       /* form nonce */
   231 	 * @since  2.0
   310       wp_nonce_field( 'import_layouts_form', 'import_layouts_nonce' );
   232 	 */
   311       
   233 	function ot_type_import_layouts() {
   312       /* format setting outer wrapper */
   234 
   313       echo '<div class="format-setting type-textarea has-desc">';
   235 		echo '<form method="post" id="import-layouts-form">';
   314         
   236 
   315         /* description */
   237 		// Form nonce.
   316         echo '<div class="description">';
   238 		wp_nonce_field( 'import_layouts_form', 'import_layouts_nonce' );
   317           
   239 
   318           if ( OT_SHOW_SETTINGS_IMPORT ) echo '<p>' . __( 'Only after you\'ve imported the Settings should you try and update your Layouts.', 'option-tree' ) . '</p>';
   240 		// Format setting outer wrapper.
   319           
   241 		echo '<div class="format-setting type-textarea has-desc">';
   320           echo '<p>' . __( 'To import your Layouts copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Layouts" button. Keep in mind that when you import your layouts, the active layout\'s saved data will write over the current data set for your Theme Options.', 'option-tree' ) . '</p>';
   242 
   321           
   243 		// Description.
   322           /* button */
   244 		echo '<div class="description">';
   323           echo '<button class="option-tree-ui-button button button-primary right hug-right">' . __( 'Import Layouts', 'option-tree' ) . '</button>';
   245 
   324           
   246 		if ( OT_SHOW_SETTINGS_IMPORT ) {
   325         echo '</div>';
   247 			echo '<p>' . esc_html__( 'Only after you\'ve imported the Settings should you try and update your Layouts.', 'option-tree' ) . '</p>';
   326         
   248 		}
   327         /* textarea */
   249 
   328         echo '<div class="format-setting-inner">';
   250 		echo '<p>' . esc_html__( 'To import your Layouts copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Layouts" button. Keep in mind that when you import your layouts, the active layout\'s saved data will write over the current data set for your Theme Options.', 'option-tree' ) . '</p>';
   329           
   251 
   330           echo '<textarea rows="10" cols="40" name="import_layouts" id="import_layouts" class="textarea"></textarea>';
   252 		echo '<button class="option-tree-ui-button button button-primary right hug-right">' . esc_html__( 'Import Layouts', 'option-tree' ) . '</button>';
   331   
   253 
   332         echo '</div>';
   254 		echo '</div>';
   333         
   255 
   334       echo '</div>';
   256 		echo '<div class="format-setting-inner">';
   335       
   257 
   336     echo '</form>';
   258 		echo '<textarea rows="10" cols="40" name="import_layouts" id="import_layouts" class="textarea"></textarea>';
   337     
   259 
   338   }
   260 		echo '</div>';
   339   
   261 
   340 }
   262 		echo '</div>';
   341 
   263 
   342 /**
   264 		echo '</form>';
   343  * Export Settings File option type.
   265 	}
   344  *
   266 }
   345  * @return    string
   267 
   346  *
       
   347  * @access    public
       
   348  * @since     2.0.8
       
   349  */
       
   350 if ( ! function_exists( 'ot_type_export_settings_file' ) ) {
   268 if ( ! function_exists( 'ot_type_export_settings_file' ) ) {
   351   
   269 
   352   function ot_type_export_settings_file() {
   270 	/**
   353     global $blog_id;
   271 	 * Export Settings File option type.
   354     
   272 	 *
   355     echo '<form method="post" id="export-settings-file-form">';
   273 	 * @access public
   356     
   274 	 * @since  2.0.8
   357       /* form nonce */
   275 	 */
   358       wp_nonce_field( 'export_settings_file_form', 'export_settings_file_nonce' );
   276 	function ot_type_export_settings_file() {
   359       
   277 		global $blog_id;
   360       /* format setting outer wrapper */
   278 
   361       echo '<div class="format-setting type-textarea simple has-desc">';
   279 		echo '<form method="post" id="export-settings-file-form">';
   362         
   280 
   363         /* description */
   281 		// Form nonce.
   364         echo '<div class="description">';
   282 		wp_nonce_field( 'export_settings_file_form', 'export_settings_file_nonce' );
   365           
   283 
   366           echo '<p>' . sprintf( __( 'Export your Settings into a fully functional %s file. If you want to add your own custom %s text domain to the file, enter it into the text field before exporting. For more information on how to use this file read the documentation on %s. Remember, you should always check the file for errors before including it in your theme.', 'option-tree' ), '<code>theme-options.php</code>', '<a href="http://codex.wordpress.org/I18n_for_WordPress_Developers" target="_blank">I18n</a>', '<a href="' . get_admin_url( $blog_id, 'admin.php?page=ot-documentation#section_theme_mode' ) . '">' . __( 'Theme Mode', 'option-tree' ) . '</a>' ) . '</p>';
   284 		// Format setting outer wrapper.
   367           
   285 		echo '<div class="format-setting type-textarea simple has-desc">';
   368         echo '</div>';
   286 
   369           
   287 		// Description.
   370         echo '<div class="format-setting-inner">';
   288 		echo '<div class="description">';
   371           
   289 
   372           echo '<input type="text" name="domain" value="" class="widefat option-tree-ui-input" placeholder="text-domain" autocomplete="off" />';
   290 		/* translators: %1$s: file name, %2$s: link to I18n docs, %3$s: link to internal docs */
   373           
   291 		$string = esc_html__( 'Export your Settings into a fully functional %1$s file. If you want to add your own custom %2$s text domain to the file, enter it into the text field before exporting. For more information on how to use this file read the documentation on %3$s. Remember, you should always check the file for errors before including it in your theme.', 'option-tree' );
   374           /* button */
   292 		echo '<p>' . sprintf( $string, '<code>theme-options.php</code>', '<a href="http://codex.wordpress.org/I18n_for_WordPress_Developers" target="_blank">I18n</a>', '<a href="' . get_admin_url( $blog_id, 'admin.php?page=ot-documentation#section_theme_mode' ) . '">' . esc_html__( 'Theme Mode', 'option-tree' ) . '</a>' ) . '</p>'; // phpcs:ignore
   375           echo '<button class="option-tree-ui-button button button-primary hug-left">' . __( 'Export Settings File', 'option-tree' ) . '</button>';
   293 
   376           
   294 		echo '</div>';
   377         echo '</div>';
   295 
   378         
   296 		echo '<div class="format-setting-inner">';
   379       echo '</div>';
   297 
   380     
   298 		echo '<input type="text" name="domain" value="" class="widefat option-tree-ui-input" placeholder="text-domain" autocomplete="off" />';
   381     echo '</form>';
   299 
   382     
   300 		echo '<button class="option-tree-ui-button button button-primary hug-left">' . esc_html__( 'Export Settings File', 'option-tree' ) . '</button>';
   383   }
   301 
   384   
   302 		echo '</div>';
   385 }
   303 
   386 
   304 		echo '</div>';
   387 /**
   305 
   388  * Export Settings option type.
   306 		echo '</form>';
   389  *
   307 	}
   390  * @return    string
   308 }
   391  *
   309 
   392  * @access    public
       
   393  * @since     2.0
       
   394  */
       
   395 if ( ! function_exists( 'ot_type_export_settings' ) ) {
   310 if ( ! function_exists( 'ot_type_export_settings' ) ) {
   396   
   311 
   397   function ot_type_export_settings() {
   312 	/**
   398     
   313 	 * Export Settings option type.
   399     /* format setting outer wrapper */
   314 	 *
   400     echo '<div class="format-setting type-textarea simple has-desc">';
   315 	 * @access public
   401       
   316 	 * @since  2.0
   402       /* description */
   317 	 */
   403       echo '<div class="description">';
   318 	function ot_type_export_settings() {
   404         
   319 
   405         echo '<p>' . __( 'Export your Settings by highlighting this text and doing a copy/paste into a blank .txt file. Then save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the <code>OptionTree->Settings->Import</code> <strong>Settings</strong> textarea on another web site.', 'option-tree' ) . '</p>';
   320 		// Format setting outer wrapper.
   406         
   321 		echo '<div class="format-setting type-textarea simple has-desc">';
   407       echo '</div>';
   322 
   408         
   323 		// Description.
   409       /* get theme options data */
   324 		echo '<div class="description">';
   410       $settings = get_option( ot_settings_id() );
   325 
   411       $settings = ! empty( $settings ) ?  ot_encode( serialize( $settings ) ) : '';
   326 		/* translators: %1$s: visual path to import, %2$s: visual path to settings */
   412         
   327 		$string = esc_html__( 'Export your Settings by highlighting this text and doing a copy/paste into a blank .txt file. Then save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the %1$s %1$s textarea on another web site.', 'option-tree' );
   413       echo '<div class="format-setting-inner">';
   328 		echo '<p>' . sprintf( $string, '<code>' . esc_html__( 'OptionTree->Settings->Import', 'option-tree' ) . '</code>', '<code>' . esc_html__( 'Settings', 'option-tree' ) . '</code>' ) . '</p>'; // phpcs:ignore
   414         echo '<textarea rows="10" cols="40" name="export_settings" id="export_settings" class="textarea">' . $settings . '</textarea>';
   329 
   415       echo '</div>';
   330 		echo '</div>';
   416       
   331 
   417     echo '</div>';
   332 		// Get theme options data.
   418     
   333 		$settings = get_option( ot_settings_id(), array() );
   419   }
   334 		$settings = ! empty( $settings ) ? ot_encode( $settings ) : '';
   420   
   335 
   421 }
   336 		echo '<div class="format-setting-inner">';
   422 
   337 		echo '<textarea rows="10" cols="40" name="export_settings" id="export_settings" class="textarea">' . $settings . '</textarea>'; // phpcs:ignore
   423 /**
   338 		echo '</div>';
   424  * Export Data option type.
   339 
   425  *
   340 		echo '</div>';
   426  * @return    string
   341 
   427  *
   342 	}
   428  * @access    public
   343 }
   429  * @since     2.0
   344 
   430  */
       
   431 if ( ! function_exists( 'ot_type_export_data' ) ) {
   345 if ( ! function_exists( 'ot_type_export_data' ) ) {
   432   
   346 
   433   function ot_type_export_data() {
   347 	/**
   434     
   348 	 * Export Data option type.
   435     /* format setting outer wrapper */
   349 	 *
   436     echo '<div class="format-setting type-textarea simple has-desc">';
   350 	 * @access public
   437       
   351 	 * @since  2.0
   438       /* description */
   352 	 */
   439       echo '<div class="description">';
   353 	function ot_type_export_data() {
   440         
   354 
   441         echo '<p>' . __( 'Export your Theme Options data by highlighting this text and doing a copy/paste into a blank .txt file. Then save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the <code>OptionTree->Settings->Import</code> <strong>Theme Options</strong> textarea on another web site.', 'option-tree' ) . '</p>';
   355 		// Format setting outer wrapper.
   442         
   356 		echo '<div class="format-setting type-textarea simple has-desc">';
   443       echo '</div>';
   357 
   444       
   358 		// Description.
   445       /* get theme options data */
   359 		echo '<div class="description">';
   446       $data = get_option( ot_options_id() );
   360 
   447       $data = ! empty( $data ) ? ot_encode( serialize( $data ) ) : '';
   361 		/* translators: %1$s: visual path to import, %2$s: visual path to theme options */
   448         
   362 		$string = esc_html__( 'Export your Theme Options data by highlighting this text and doing a copy/paste into a blank .txt file. Then save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the %1$s %2$s textarea on another web site.', 'option-tree' );
   449       echo '<div class="format-setting-inner">';
   363 		echo '<p>' . sprintf( $string, '<code>' . esc_html__( 'OptionTree->Settings->Import', 'option-tree' ) . '</code>', '<code>' . esc_html__( 'Theme Options', 'option-tree' ) . '</code>' ) . '</p>'; // phpcs:ignore
   450         echo '<textarea rows="10" cols="40" name="export_data" id="export_data" class="textarea">' . $data . '</textarea>';
   364 
   451       echo '</div>';
   365 		echo '</div>';
   452       
   366 
   453     echo '</div>';
   367 		// Get theme options data.
   454     
   368 		$data = get_option( ot_options_id(), array() );
   455   }
   369 		$data = ! empty( $data ) ? ot_encode( $data ) : '';
   456   
   370 
   457 }
   371 		echo '<div class="format-setting-inner">';
   458 
   372 		echo '<textarea rows="10" cols="40" name="export_data" id="export_data" class="textarea">' . $data . '</textarea>'; // phpcs:ignore
   459 /**
   373 		echo '</div>';
   460  * Export Layouts option type.
   374 
   461  *
   375 		echo '</div>';
   462  * @return    string
   376 
   463  *
   377 	}
   464  * @access    public
   378 }
   465  * @since     2.0
   379 
   466  */
       
   467 if ( ! function_exists( 'ot_type_export_layouts' ) ) {
   380 if ( ! function_exists( 'ot_type_export_layouts' ) ) {
   468   
   381 
   469   function ot_type_export_layouts() {
   382 	/**
   470     
   383 	 * Export Layouts option type.
   471     /* format setting outer wrapper */
   384 	 *
   472     echo '<div class="format-setting type-textarea simple has-desc">';
   385 	 * @access public
   473       
   386 	 * @since  2.0
   474       /* description */
   387 	 */
   475       echo '<div class="description">';
   388 	function ot_type_export_layouts() {
   476         
   389 
   477         echo '<p>' . __( 'Export your Layouts by highlighting this text and doing a copy/paste into a blank .txt file. Then save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the <code>OptionTree->Settings->Import</code> <strong>Layouts</strong> textarea on another web site.', 'option-tree' ) . '</p>';
   390 		// Format setting outer wrapper.
   478         
   391 		echo '<div class="format-setting type-textarea simple has-desc">';
   479         
   392 
   480       echo '</div>';
   393 		// Description.
   481       
   394 		echo '<div class="description">';
   482       /* get layout data */
   395 
   483       $layouts = get_option( ot_layouts_id() );
   396 		/* translators: %1$s: visual path to import, %2$s: visual path to layouts */
   484       $layouts = ! empty( $layouts ) ? ot_encode( serialize( $layouts ) ) : '';
   397 		$string = esc_html__( 'Export your Layouts by highlighting this text and doing a copy/paste into a blank .txt file. Then save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the %1$s %2$s textarea on another web site.', 'option-tree' );
   485         
   398 		echo '<p>' . sprintf( $string, '<code>' . esc_html__( 'OptionTree->Settings->Import', 'option-tree' ) . '</code>', '<code>' . esc_html__( 'Layouts', 'option-tree' ) . '</code>' ) . '</p>'; // phpcs:ignore
   486       echo '<div class="format-setting-inner">';
   399 
   487         echo '<textarea rows="10" cols="40" name="export_layouts" id="export_layouts" class="textarea">' . $layouts . '</textarea>';
   400 		echo '</div>';
   488       echo '</div>';
   401 
   489       
   402 		// Get layout data.
   490     echo '</div>';
   403 		$layouts = get_option( ot_layouts_id(), array() );
   491     
   404 		$layouts = ! empty( $layouts ) ? ot_encode( $layouts ) : '';
   492   }
   405 
   493   
   406 		echo '<div class="format-setting-inner">';
   494 }
   407 		echo '<textarea rows="10" cols="40" name="export_layouts" id="export_layouts" class="textarea">' . $layouts . '</textarea>'; // phpcs:ignore
   495 
   408 		echo '</div>';
   496 /**
   409 
   497  * Modify Layouts option type.
   410 		echo '</div>';
   498  *
   411 	}
   499  * @return    string
   412 }
   500  *
   413 
   501  * @access    public
       
   502  * @since     2.0
       
   503  */
       
   504 if ( ! function_exists( 'ot_type_modify_layouts' ) ) {
   414 if ( ! function_exists( 'ot_type_modify_layouts' ) ) {
   505   
   415 
   506   function ot_type_modify_layouts() {
   416 	/**
   507     
   417 	 * Modify Layouts option type.
   508     echo '<form method="post" id="option-tree-settings-form">';
   418 	 *
   509       
   419 	 * @access public
   510       /* form nonce */
   420 	 * @since  2.0
   511       wp_nonce_field( 'option_tree_modify_layouts_form', 'option_tree_modify_layouts_nonce' );
   421 	 */
   512 
   422 	function ot_type_modify_layouts() {
   513       /* format setting outer wrapper */
   423 
   514       echo '<div class="format-setting type-textarea has-desc">';
   424 		echo '<form method="post" id="option-tree-settings-form">';
   515           
   425 
   516         /* description */
   426 		// Form nonce.
   517         echo '<div class="description">';
   427 		wp_nonce_field( 'option_tree_modify_layouts_form', 'option_tree_modify_layouts_nonce' );
   518           
   428 
   519           echo '<p>' . __( 'To add a new layout enter a unique lower case alphanumeric string (dashes allowed) in the text field and click "Save Layouts".', 'option-tree' ) . '</p>';
   429 		// Format setting outer wrapper.
   520           echo '<p>' . __( 'As well, you can activate, remove, and drag & drop the order; all situations require you to click "Save Layouts" for the changes to be applied.', 'option-tree' ) . '</p>';
   430 		echo '<div class="format-setting type-textarea has-desc">';
   521           echo '<p>' . __( 'When you create a new layout it will become active and any changes made to the Theme Options will be applied to it. If you switch back to a different layout immediately after creating a new layout that new layout will have a snapshot of the current Theme Options data attached to it.', 'option-tree' ) . '</p>';
   431 
   522           if ( OT_SHOW_DOCS ) echo '<p>' . __( 'Visit <code>OptionTree->Documentation->Layouts Overview</code> to see a more in-depth description of what layouts are and how to use them.', 'option-tree' ) . '</p>';
   432 		// Description.
   523           
   433 		echo '<div class="description">';
   524         echo '</div>';
   434 
   525         
   435 		echo '<p>' . esc_html__( 'To add a new layout enter a unique lower case alphanumeric string (dashes allowed) in the text field and click "Save Layouts".', 'option-tree' ) . '</p>';
   526         echo '<div class="format-setting-inner">';
   436 		echo '<p>' . esc_html__( 'As well, you can activate, remove, and drag & drop the order; all situations require you to click "Save Layouts" for the changes to be applied.', 'option-tree' ) . '</p>';
   527  
   437 		echo '<p>' . esc_html__( 'When you create a new layout it will become active and any changes made to the Theme Options will be applied to it. If you switch back to a different layout immediately after creating a new layout that new layout will have a snapshot of the current Theme Options data attached to it.', 'option-tree' ) . '</p>';
   528           /* get the saved layouts */
   438 
   529           $layouts = get_option( ot_layouts_id() );
   439 		if ( OT_SHOW_DOCS ) {
   530       
   440 			/* translators: %s: visual path to layouts overview */
   531           /* set active layout */
   441 			$string = esc_html__( 'Visit %s to see a more in-depth description of what layouts are and how to use them.', 'option-tree' );
   532           $active_layout = isset( $layouts['active_layout'] ) ? $layouts['active_layout'] : '';
   442 			echo '<p>' . sprintf( $string, '<code>' . esc_html__( 'OptionTree->Documentation->Layouts Overview', 'option-tree' ) . '</code>' ) . '</p>'; // phpcs:ignore
   533           
   443 		}
   534           echo '<input type="hidden" name="' . ot_layouts_id() . '[active_layout]" value="' . esc_attr( $active_layout ) . '" class="active-layout-input" />';
   444 
   535           
   445 		echo '</div>';
   536           /* add new layout */
   446 
   537           echo '<input type="text" name="' . ot_layouts_id() . '[_add_new_layout_]" value="" class="widefat option-tree-ui-input" autocomplete="off" />';
   447 		echo '<div class="format-setting-inner">';
   538            
   448 
   539           /* loop through each layout */
   449 		// Get the saved layouts.
   540           echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_layouts">';
   450 		$layouts = get_option( ot_layouts_id() );
   541           
   451 
   542           if ( is_array( $layouts ) && ! empty( $layouts ) ) {
   452 		// Set active layout.
   543           
   453 		$active_layout = isset( $layouts['active_layout'] ) ? $layouts['active_layout'] : '';
   544             foreach( $layouts as $key => $data ) {
   454 
   545               
   455 		echo '<input type="hidden" name="' . esc_attr( ot_layouts_id() ) . '[active_layout]" value="' . esc_attr( $active_layout ) . '" class="active-layout-input" />';
   546               /* skip active layout array */
   456 
   547               if ( $key == 'active_layout' )
   457 		// Add new layout.
   548                 continue;
   458 		echo '<input type="text" name="' . esc_attr( ot_layouts_id() ) . '[_add_new_layout_]" value="" class="widefat option-tree-ui-input" autocomplete="off" />';
   549                 
   459 
   550               /* content */
   460 		// Loop through each layout.
   551               echo '<li class="ui-state-default list-layouts">' . ot_layout_view( $key, $data, $active_layout ) . '</li>';
   461 		echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_layouts">';
   552 
   462 
   553             }
   463 		if ( is_array( $layouts ) && ! empty( $layouts ) ) {
   554             
   464 
   555           }
   465 			foreach ( $layouts as $key => $data ) {
   556           
   466 
   557           echo '</ul>';
   467 				// Skip active layout array.
   558             
   468 				if ( 'active_layout' === $key ) {
   559           echo '<button class="option-tree-ui-button button button-primary right hug-right">' . __( 'Save Layouts', 'option-tree' ) . '</button>';
   469 					continue;
   560             
   470 				}
   561         echo '</div>';
   471 
   562         
   472 				// Content.
   563       echo '</div>';
   473 				echo '<li class="ui-state-default list-layouts">' . ot_layout_view( $key, $data, $active_layout ) . '</li>'; // phpcs:ignore
   564     
   474 			}
   565     echo '</form>';
   475 		}
   566     
   476 
   567   }
   477 		echo '</ul>';
   568   
   478 
   569 }
   479 		echo '<button class="option-tree-ui-button button button-primary right hug-right">' . esc_html__( 'Save Layouts', 'option-tree' ) . '</button>';
   570 
   480 
   571 /* End of file ot-functions-settings-page.php */
   481 		echo '</div>';
   572 /* Location: ./includes/ot-functions-settings-page.php */
   482 
       
   483 		echo '</div>';
       
   484 
       
   485 		echo '</form>';
       
   486 	}
       
   487 }