helper.php
3 years ago
share-style-settings.php
3 years ago
social-share-style.php
3 years ago
user-helper.php
3 years ago
view-helper.php
3 years ago
view-helper.php
109 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WP_Social\Helper; |
| 4 | |
| 5 | defined('ABSPATH') || exit; |
| 6 | |
| 7 | class View_Helper { |
| 8 | |
| 9 | /* |
| 10 | -------------------------------------- |
| 11 | for differet tyep of yes/no switches |
| 12 | ------------------------------------- |
| 13 | */ |
| 14 | |
| 15 | public static function get_enable_switch($identifier, $checked = false, $onchange_dom_handler = '', $extra_class = '') { |
| 16 | |
| 17 | $id = $identifier.'_enable'; |
| 18 | $nm = 'xs_social['. $identifier .'][enable]'; ?> |
| 19 | |
| 20 | <input |
| 21 | class="social_switch_button social_switch_button <?php echo esc_attr($extra_class) ?>" |
| 22 | type="checkbox" |
| 23 | value="1" |
| 24 | id="<?php echo esc_attr($id) ?>" |
| 25 | name="<?php echo esc_attr($nm); ?>" |
| 26 | data-key="<?php echo esc_attr($identifier); ?>" |
| 27 | <?php if(!empty($onchange_dom_handler)): ?> |
| 28 | onchange="<?php echo esc_html($onchange_dom_handler);?>(this)" |
| 29 | <?php endif; ?> |
| 30 | |
| 31 | <?php echo esc_attr($checked ? '' : 'checked') ?> /> |
| 32 | |
| 33 | <label for="<?php echo esc_attr($id); ?>" class="social_switch_button_label"></label> |
| 34 | |
| 35 | <?php |
| 36 | } |
| 37 | |
| 38 | /* |
| 39 | -------------------------------------- |
| 40 | for page or post select2 dropdown list |
| 41 | ------------------------------------- |
| 42 | */ |
| 43 | public static function get_select2_dropdown( $post_type = 'page', $status = 'publish', $default = '', $name = '' ) { |
| 44 | |
| 45 | $args = array( |
| 46 | 'sort_order' => 'asc', |
| 47 | 'sort_column' => 'post_title', |
| 48 | 'post_type' => $post_type, |
| 49 | 'post_status' => $status |
| 50 | ); |
| 51 | |
| 52 | ?> |
| 53 | <div class="wp-social-select-2-dropdown--wrapper"> |
| 54 | <select name="<?php echo esc_attr($name) ?>" class="wp-social-select-2-dropdown"> |
| 55 | <?php foreach( get_pages($args) as $page ): ?> |
| 56 | <option <?php echo esc_attr($page->guid == $default ? 'selected' : '') ?> value="<?php echo esc_url( $page->guid ) ?>"> <?php echo esc_html( $page->post_title ) ?> </option> |
| 57 | <?php endforeach; ?> |
| 58 | </select> |
| 59 | </div> |
| 60 | <?php |
| 61 | |
| 62 | } // end of get_select2_dropdown |
| 63 | |
| 64 | /* |
| 65 | ----------------------- |
| 66 | for style card design |
| 67 | ----------------------- |
| 68 | */ |
| 69 | public static function get_style_card( $arg ) { |
| 70 | |
| 71 | extract($arg); |
| 72 | $is_active = (isset($saved_style) && $saved_style == $style ) ? 'wslu-active' : ''; |
| 73 | $is_checked = (isset($saved_style) && $saved_style == $style ) ? 'checked' : ''; |
| 74 | $parentClass = $is_active . ' ' . 'wslu--'.$package; |
| 75 | |
| 76 | ?> |
| 77 | <div class="wslu-style-card <?php echo esc_attr($parentClass) ?> "> |
| 78 | <label |
| 79 | class="wslu-style-card__label" |
| 80 | for="wslu-style-card--<?php echo esc_attr($key) ?>"> |
| 81 | |
| 82 | <div class="wslu-style-card__label--image"> |
| 83 | <img |
| 84 | src="<?php echo esc_url( $image ); ?>" |
| 85 | alt="<?php echo esc_attr( $title) ?>"> |
| 86 | </div> |
| 87 | |
| 88 | <div class="wslu-style-card__label__input"> |
| 89 | <input <?php echo esc_attr( $is_checked ) ?> |
| 90 | class = "wslu-style-card__label__input--radio" |
| 91 | type = "radio" |
| 92 | id = "wslu-style-card--<?php echo esc_attr($key) ?>" |
| 93 | name = "<?php echo esc_attr( $name ) ?>" |
| 94 | value = "<?php echo esc_attr( $style ) ?>" |
| 95 | /> |
| 96 | |
| 97 | <?php |
| 98 | echo esc_html__($title, 'wp-social'); |
| 99 | if( $package == 'pro' ) echo wp_kses('<strong >(Pro Only)</strong>' , \WP_Social\Helper\Helper::get_kses_array()); |
| 100 | ?> |
| 101 | </div> |
| 102 | |
| 103 | </label> |
| 104 | </div> |
| 105 | <?php |
| 106 | } |
| 107 | |
| 108 | } |
| 109 |