IŠÀ qUR”<9sÀ qUPÐ @•pƃÀ qUÐ P•tIŠÀ qUS•<9sÀ qUP  P–pƃÀ qU  P–tÀ qU»÷# `–p­|À qUp p–=o‰À qUP'–<y`À qUP'` x–pƃÀ qU` P–to‰À qU`'–<—’À qU`'P–2ƃÀ qU `–to‰À qUp'–<—’À qUp'`–2IŠÀ qUW–<9sÀ qUP  ˆ—pIŠÀ qUX—<9sÀ qUP€ ˜™pƃÀ qU€ P™tIŠÀ qUY™<9sÀ qUPP ¨špƃÀ qUP Pšt9sÀ qUP@ ¸šp­|À qUp@ Èš=o‰À qU°'š<y`À qU°' КpƃÀ qU Pšto‰À qUÀ'š<—’À qUÀ'Pš2­|À qUpÀ àš=o‰À qUÐ'š<y`À qUÐ' èšpƃÀ qU Pšto‰À qUà'š<—’À qUà'`š2o‰À qUð'š<—’À qUð'`š2IŠÀ qU_š<9sÀ qUPàø›pƃÀ qUàP›t9sÀ qUPЛp­|À qUpЛ=o‰À qU(›<y`À qU(  ›pƃÀ qU P›to‰À qU (›<—’À qU (P›2o‰À qU0(›<—’À qU0(`›2IŠÀ qUc›<9sÀ qUPð0pƃÀ qUðPtIŠÀ qUd<9sÀ qUPÀ@žpƃÀ qUÀPžt9sÀ qUP°Pžp­|À qUp°`ž=o‰À qU`(ž<y`À qU`(€hžpƃÀ qU€Pžto‰À qUp(ž<—’À qUp(Pž2o‰À qU€(ž<—’À qU€(`ž2IŠÀ qUhž<­|À qUpÐxŸ=o‰À qU (Ÿ<y`À qU ( €ŸpƃÀ qU PŸtƃÀ qU`Ÿto‰À qU°(Ÿ<±SÀ qU°(kŸ¨ŒÀ qU@ EWyÀ qUP Bo‰À qUÐ( <±aÀ qUÐ(à( .ÈLÀ qUðð( sÕaÀ qUð() ¥aÀ qU)€) /ÈLÀ qU ) sÕaÀ qU) ) aÀ qU )) 4¥aÀ qU)€) /ÈLÀ qU00) sÕaÀ qU0)@) aÀ qU@)) 4¥aÀ qU)€) /ÈLÀ qUÀP) sÕaÀ qUP)`) aÀ qU`)) 4aÀ qU)à( 4ªmÀ qUà(  +9sÀ qUP0˜¡pƃÀ qU0P¡tƃÀ qU `¡tIŠÀ qUv¡<­|À qUpð¨£=o‰À qU€)£<y`À qU€)À°£pƃÀ qUÀP£tƃÀ qU°`£to‰À qU)£<ªmÀ qU)  £+9sÀ qUP`À¤pƃÀ qU`P¤t9sÀ qUPPФp­|À qUpPà¤=o‰À qU )¤<y`À qU ) è¤pƃÀ qU P¤to‰À qU°)¤<—’À qU°)P¤2­|À qUpÐø¤=o‰À qUÀ)¤<y`À qUÀ) ¤pƃÀ qU P¤to‰À qUÐ)¤<—’À qUÐ)`¤2o‰À qUà)¤<—’À qUà)`¤2IŠÀ qU~¤<9sÀ qUPð¥pƃÀ qUðP¥tIŠÀ qU¥<9sÀ qUPÀ ¦pƃÀ qUÀP¦t, 10, 3 ); } } } /** * Add additional column for the taxonomy image. * * @param array $columns Existing taxonomy columns. * * @return array */ final public function taxonomy_term_column_image( $columns ) { $columns['term_image'] = __( 'Image', 'neve-pro-addon' ); return $columns; } /** * Retrieve the content for the image column. * * @param string $content The content of the column. * @param string $column_name The column name. * @param integer $term_id The term ID. * * @return string */ final public function taxonomy_term_column_image_content( $content, $column_name, $term_id ) { if ( 'term_image' == $column_name ) { $term = get_term( $term_id, '', 'ARRAY_A' ); if ( is_wp_error( $term ) ) { return $content; } if ( $term[ $this->term_meta_key ] ) { $content = wp_get_attachment_image( $term[ $this->term_meta_key ], 'thumbnail', false, array( 'style' => 'width:100%; max-width:48px; height:auto;' ) ); } } return $content; } /** * Append image meta to taxonomy information. * * @param mixed $_term A WordPress term object. * * @return mixed */ final public function get_term( $_term ) { // only modify term when dealing with our taxonomies if ( is_object( $_term ) && in_array( $_term->taxonomy, $this->taxonomies ) ) { // default to null if not found $image_id = get_term_meta( $_term->term_id, $this->term_meta_key, true ); $_term->term_image = ! empty( $image_id ) ? $image_id : null; } return $_term; } /** * Return all terms with additional image meta. * * @param array $terms A list of term objects. * * @return array */ final public function get_terms( $terms ) { foreach ( $terms as $i => $term ) { if ( is_object( $term ) && ! empty( $term->taxonomy ) ) { $terms[ $i ] = $this->get_term( $term ); } } return $terms; } /** * Enqueue media library for taxonomy script */ final public function taxonomy_media_library_enqueue_scripts() { $screen = get_current_screen(); foreach ( $this->taxonomies as $taxonomy ) { if ( isset( $screen->id ) && $screen->id == 'edit-' . $taxonomy ) { $term = get_taxonomy( $taxonomy ); // WP core stuff we need wp_enqueue_media(); wp_enqueue_style( 'thickbox' ); wp_register_script( 'nv-taxonomy-term-image-js', NEVE_PRO_INCLUDES_URL . 'modules/header_footer_grid/assets/js/taxonomy_image_library.js', array( 'jquery', 'thickbox', 'media-upload' ), NEVE_PRO_VERSION, true ); $labels = $this->labels; $labels['fieldDescription'] = sprintf( $labels['fieldDescription'], $term->labels->singular_name ); $labels['modalTitle'] = sprintf( $labels['modalTitle'], $term->labels->singular_name ); wp_localize_script( 'nv-taxonomy-term-image-js', 'TaxonomyTermTranslations', $labels ); wp_enqueue_script( 'nv-taxonomy-term-image-js' ); break; } } } /** * Return the image field for the provided image ID. * * @param null|integer $image_id The image ID. * @param boolean $echo Flag to specify if it should echo the $output. * * @return string|void */ final public function taxonomy_term_image_field( $image_id = null, $echo = true ) { $image_src = ( $image_id ) ? wp_get_attachment_image_src( $image_id, 'thumbnail' ) : array(); wp_nonce_field( 'taxonomy-term-image-form-save', 'taxonomy-term-image-save-form-nonce' ); $image = ''; if ( isset( $image_src[0] ) ) { $image = ''; } $taxonomy = isset( $_GET['taxonomy'] ) ? sanitize_text_field( $_GET['taxonomy'] ) : ''; $term = get_taxonomy( $taxonomy ); $labels = $this->labels; $labels['fieldDescription'] = sprintf( $labels['fieldDescription'], $term->labels->singular_name ); $output = '
' . $image . '

' . $labels['fieldDescription'] . '

'; if ( $echo ) { echo wp_kses( $output, $this->allowed_html ); return; } return $output; } /** * The taxonomy featured image add form template. * * @return void */ final public function taxonomy_add_form() { echo '
' . wp_kses( $this->taxonomy_term_image_field( null, false ), $this->allowed_html ) . '
'; } /** * The taxonomy featured image edit form template. * * @param mixed $term The WordPress term object. * * @return void */ final public function taxonomy_edit_form( $term ) { if ( ! isset( $term->term_image ) ) { $term = $this->get_term( $term ); } echo ' ' . wp_kses( $this->taxonomy_term_image_field( $term->term_image, false ), $this->allowed_html ) . ' '; } /** * Save the featured image meta for the provided term ID. * * @param integer $term_id The term ID. * * @return void */ final public function taxonomy_term_form_save( $term_id ) { // our requirements for saving: if ( // nonce was submitted and is verified isset( $_POST['taxonomy-term-image-save-form-nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['taxonomy-term-image-save-form-nonce'] ), 'taxonomy-term-image-form-save' ) && // taxonomy data and taxonomy_term_image data was submitted isset( $_POST['taxonomy'] ) && isset( $_POST['taxonomy_term_image'] ) && // the taxonomy submitted is one of the taxonomies we are dealing with in_array( $_POST['taxonomy'], $this->taxonomies ) ) { // get the term_meta and assign it the old_image $old_image = get_term_meta( $term_id, $this->term_meta_key, true ); // sanitize the data and save it as the new_image $new_image = absint( $_POST['taxonomy_term_image'] ); // if an image was removed, delete the meta data if ( $old_image && empty( $new_image ) ) { delete_term_meta( $term_id, $this->term_meta_key ); } elseif ( $old_image !== $new_image ) { // if the new image is not the same as the old update the term_meta update_term_meta( $term_id, $this->term_meta_key, $new_image ); if ( Loader::has_compatibility( 'track' ) ) { \Neve\Core\Tracker::track( array( array( 'feature' => 'taxonomy-featured-image', 'featureComponent' => 'image-upload', 'featureValue' => true, ), ) ); } } } } /** * Cloning is forbidden. * * @access protected * @since 3.0.0 */ protected function __clone(){} /** * Un-serializing instances of this class is forbidden. * * @access public * @since 3.0.0 */ public function __wakeup(){} }