helper.php
1 week ago
share-style-settings.php
3 years ago
social-share-style.php
1 week ago
user-helper.php
3 years ago
view-helper.php
1 week ago
view-helper.php
117 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 = '', $include_same_page = false ) { |
| 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 if( $include_same_page ): ?> |
| 56 | <option <?php echo esc_attr($default == 'same_page' ? 'selected' : '') ?> value="same_page"><?php echo esc_html__('Same Page', 'wp-social') ?></option> |
| 57 | <?php endif; ?> |
| 58 | <?php foreach( get_pages($args) as $page ): ?> |
| 59 | <option <?php echo esc_attr($page->guid == $default ? 'selected' : '') ?> value="<?php echo esc_url( $page->guid ) ?>"> <?php echo esc_html( $page->post_title ) ?> </option> |
| 60 | <?php endforeach; ?> |
| 61 | </select> |
| 62 | </div> |
| 63 | <?php |
| 64 | |
| 65 | } // end of get_select2_dropdown |
| 66 | |
| 67 | /* |
| 68 | ----------------------- |
| 69 | for style card design |
| 70 | ----------------------- |
| 71 | */ |
| 72 | public static function get_style_card( $arg ) { |
| 73 | |
| 74 | extract($arg); |
| 75 | $is_active = (isset($saved_style) && $saved_style == $style ) ? 'wslu-active' : ''; |
| 76 | $is_checked = (isset($saved_style) && $saved_style == $style ) ? 'checked' : ''; |
| 77 | $parentClass = $is_active . ' ' . 'wslu--'.$package; |
| 78 | |
| 79 | ?> |
| 80 | <div class="wslu-style-card <?php echo esc_attr($parentClass) ?> "> |
| 81 | <label |
| 82 | class="wslu-style-card__label" |
| 83 | for="wslu-style-card--<?php echo esc_attr($key) ?>"> |
| 84 | |
| 85 | <div class="wslu-style-card__label--image"> |
| 86 | <img |
| 87 | src="<?php echo esc_url( $image ); ?>" |
| 88 | alt="<?php echo esc_attr( $title) ?>"> |
| 89 | |
| 90 | </div> |
| 91 | <?php if ( $package == 'pro' ) : ?> |
| 92 | <a href="https://wpmet.com/plugin/wp-social/pricing/" class="wslu-buy-now-btn" target="_blank" rel="noopener noreferrer" onclick="event.stopPropagation();"><?php esc_html_e( 'Buy Now', 'wp-social' ); ?></a> |
| 93 | <?php endif; ?> |
| 94 | |
| 95 | <div class="wslu-style-card__label__input"> |
| 96 | <input <?php echo esc_attr( $is_checked ) ?> |
| 97 | class = "wslu-style-card__label__input--radio" |
| 98 | type = "radio" |
| 99 | id = "wslu-style-card--<?php echo esc_attr($key) ?>" |
| 100 | name = "<?php echo esc_attr( $name ) ?>" |
| 101 | value = "<?php echo esc_attr( $style ) ?>" |
| 102 | /> |
| 103 | |
| 104 | <?php |
| 105 | echo esc_html__($title, 'wp-social'); |
| 106 | if( $package == 'pro' ) echo wp_kses('<strong >(' . esc_html__('Pro Only', 'wp-social') . ')</strong>' , \WP_Social\Helper\Helper::get_kses_array()); |
| 107 | |
| 108 | ?> |
| 109 | </div> |
| 110 | |
| 111 | </label> |
| 112 | </div> |
| 113 | <?php |
| 114 | } |
| 115 | |
| 116 | } |
| 117 |