????JFIF??x?x????'
| Server IP : 79.136.114.73 / Your IP : 216.73.216.48 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/www.astacus.se/wp-content/themes/x/framework/functions/global/admin/meta/ |
Upload File : |
<?php
// =============================================================================
// FUNCTIONS/GLOBAL/ADMIN/META/TAXONOMIES.PHP
// -----------------------------------------------------------------------------
// Implement the meta boxes for taxonomy pages.
// =============================================================================
// =============================================================================
// TABLE OF CONTENTS
// -----------------------------------------------------------------------------
// 01. Add New Taxonomy Page
// 02. Edit Taxonomy Page
// 03. Save Taxonomy Meta
// 04. Taxonomy Actions
// 05. Get Taxonomy Meta
// =============================================================================
// Add New Taxonomy Page
// =============================================================================
function x_taxonomy_add_new_meta_field() {
$stack = x_get_stack();
$archive_title_display = ( $stack != 'icon' ) ? 'style="display: block;"' : 'style="display: none;"';
$archive_subtitle_display = ( $stack == 'integrity' ) ? 'style="display: block;"' : 'style="display: none;"';
$accent_display = ( $stack == 'ethos' ) ? 'style="display: block;"' : 'style="display: none;"';
?>
<div class="form-field" <?php echo $archive_title_display; ?>>
<label for="term_meta[archive-title]"><?php _e( 'Archive Title', '__x__' ); ?></label>
<input type="text" name="term_meta[archive-title]" id="term_meta[archive-title]" value="">
<p><?php _e( 'Enter in a value to overwrite the default title of the archive page.', '__x__' ); ?></p>
</div>
<div class="form-field" <?php echo $archive_subtitle_display; ?>>
<label for="term_meta[archive-subtitle]"><?php _e( 'Archive Subtitle', '__x__' ); ?></label>
<input type="text" name="term_meta[archive-subtitle]" id="term_meta[archive-subtitle]" value="">
<p><?php _e( 'Enter in a value to overwrite the default subtitle of the archive page.', '__x__' ); ?></p>
</div>
<div class="form-field" <?php echo $accent_display; ?>>
<label for="term_meta[accent]"><?php _e( 'Accent', '__x__' ); ?></label>
<input type="text" name="term_meta[accent]" id="term_meta[accent]" class="wp-color-picker" value="#ffffff" data-default-color="#ffffff">
<p><?php _e( 'Choose an accent color to be used for certain design elements.', '__x__' ); ?></p>
</div>
<?php
}
// Edit Taxonomy Page
// =============================================================================
function x_taxonomy_edit_meta_field( $term ) {
$stack = x_get_stack();
$archive_title_display = ( $stack != 'icon' ) ? 'style="display: table-row;"' : 'style="display: none;"';
$archive_subtitle_display = ( $stack == 'integrity' ) ? 'style="display: table-row;"' : 'style="display: none;"';
$accent_display = ( $stack == 'ethos' ) ? 'style="display: table-row;"' : 'style="display: none;"';
$t_id = $term->term_id;
$term_meta = get_option( 'taxonomy_' . $t_id );
?>
<tr class="form-field" <?php echo $archive_title_display; ?>>
<th scope="row" valign="top">
<label for="term_meta[archive-title]"><?php _e( 'Archive Title', '__x__' ); ?></label>
</th>
<td>
<input type="text" name="term_meta[archive-title]" id="term_meta[archive-title]" value="<?php echo esc_attr( $term_meta['archive-title'] ) ? esc_attr( $term_meta['archive-title'] ) : ''; ?>">
<p class="description"><?php _e( 'Enter in a value to overwrite the default title of the archive page.', '__x__' ); ?></p>
</td>
</tr>
<tr class="form-field" <?php echo $archive_subtitle_display; ?>>
<th scope="row" valign="top">
<label for="term_meta[archive-subtitle]"><?php _e( 'Archive Subtitle', '__x__' ); ?></label>
</th>
<td>
<input type="text" name="term_meta[archive-subtitle]" id="term_meta[archive-subtitle]" value="<?php echo esc_attr( $term_meta['archive-subtitle'] ) ? esc_attr( $term_meta['archive-subtitle'] ) : ''; ?>">
<p class="description"><?php _e( 'Enter in a value to overwrite the default subtitle of the archive page.', '__x__' ); ?></p>
</td>
</tr>
<tr class="form-field" <?php echo $accent_display; ?>>
<th scope="row" valign="top">
<label for="term_meta[accent]"><?php _e( 'Accent', '__x__' ); ?></label>
</th>
<td>
<input type="text" name="term_meta[accent]" id="term_meta[accent]" class="wp-color-picker" value="<?php echo esc_attr( $term_meta['accent'] ) ? esc_attr( $term_meta['accent'] ) : '#ffffff'; ?>" data-default-color="#ffffff">
<p class="description"><?php _e( 'Choose an accent color to be used for certain design elements.', '__x__' ); ?></p>
</td>
</tr>
<?php
}
// Save Taxonomy Meta
// =============================================================================
function x_taxonomy_save_custom_meta( $term_id ) {
if ( isset( $_POST['term_meta'] ) ) {
$t_id = $term_id;
$term_meta = get_option( 'taxonomy_' . $t_id );
$cat_keys = array_keys( $_POST['term_meta'] );
foreach ( $cat_keys as $key ) {
if ( isset ( $_POST['term_meta'][$key] ) ) {
$term_meta[$key] = wp_kses_post( stripslashes( $_POST['term_meta'][$key] ) );
}
}
update_option( 'taxonomy_' . $t_id, $term_meta );
}
}
// Taxonomy Actions
// =============================================================================
$taxonomies = array(
'category',
'post_tag',
'portfolio-category',
'portfolio-tag',
'product_cat',
'product_tag'
);
foreach ( $taxonomies as $tax ) {
add_action( $tax . '_add_form_fields', 'x_taxonomy_add_new_meta_field', 10, 2 );
add_action( $tax . '_edit_form_fields', 'x_taxonomy_edit_meta_field', 10, 2 );
add_action( 'edited_' . $tax, 'x_taxonomy_save_custom_meta', 10, 2 );
add_action( 'create_' . $tax, 'x_taxonomy_save_custom_meta', 10, 2 );
}
// Get Taxonomy Meta
// =============================================================================
function x_get_taxonomy_meta() {
$object = get_queried_object();
$id = $object->term_id;
$meta = get_option( 'taxonomy_' . $id );
return $meta;
}