| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- /* ============== Services category meta add field ============ */
- if (!function_exists('taskereasy_category_meta_add')) {
- add_action( 'servicecategories_add_form_fields', 'taskereasy_category_meta_add' );
- function taskereasy_category_meta_add() {
- ?>
- <tr id="service_icon">
- <th>
- <label for="service_icon">
- <?php _e( 'Icon', 'taskereasy' ); ?>
- </label>
- </th>
- <td>
- <input type="text" id="service_icon" name="service_icon" value="" placeholder="Image URL" size="" />
- <a href="javascript:void(0)" class="button insert-images theme_button format" onclick="browseimage('service_icon');"><?php esc_html_e('Insert image', "cland"); ?></a>
- <p class="description">Add image</p>
- </td>
- </tr>
- <?php
- }
- }
- /* ============== Services category meta edit ============ */
- if (!function_exists('taskereasy_category_meta_edit')) {
- add_action( 'servicecategories_edit_form_fields', 'taskereasy_category_meta_edit' );
- function taskereasy_category_meta_edit( $term ) {
- $term_image = get_term_meta( $term->term_id, 'service_icon', true );
- ?>
- <tr id="service_icon" class="form-field">
- <th>
- <label for="service_icon">
- <?php _e( 'Icon', 'taskereasy' ); ?>
- </label>
- </th>
- <td>
- <?php if(!empty($term_image)){ ?>
- <img src="<?php echo $term_image; ?>" alt="service category image" width="50" id="service_img">
- <?php } ?>
- <input type="text" id="service_icon" name="service_icon" value="<?php echo $term_image; ?>" placeholder="Image URL" size="" />
- <a href="javascript:void(0)" class="button insert-images theme_button format" onclick="browseimage('service_icon');"><?php esc_html_e('Add image', "cland"); ?></a>
- <a href="javascript:void(0)" class="button insert-images theme_button format" onclick="removeimage('service_icon');"><?php esc_html_e('Remove', "cland"); ?></a>
- <p class="description">Add image</p>
- </td>
- </tr>
- <?php
- }
- }
- /* ============== Services category meta save ============ */
- if (!function_exists('servicecategories_category_meta_save')) {
- add_action( 'edited_servicecategories', 'servicecategories_category_meta_save' );
- add_action( 'create_servicecategories', 'servicecategories_category_meta_save' );
- function servicecategories_category_meta_save( $term_id ) {
- if ( isset( $_POST['service_icon'] ) ) {
- $term_image = $_POST['service_icon'];
- if( $term_image ) {
- update_term_meta( $term_id, 'service_icon', $term_image );
- }
- else{
- delete_term_meta( $term_id, 'service_icon', $term_image );
- }
- }
- }
- }
|