| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Class for Promotion. |
| 5 |
* |
| 6 |
* @since 1.0.17 |
| 7 |
* @version 1.5.12 |
| 8 |
* @access public |
| 9 |
*/ |
| 10 |
class LoginPress_Promo extends WP_Customize_Control { |
| 11 |
|
| 12 |
/** |
| 13 |
* The type of customize control being rendered. |
| 14 |
* |
| 15 |
* @since 1.0.17 |
| 16 |
* @access public |
| 17 |
* @var string |
| 18 |
*/ |
| 19 |
public $type = 'promotion'; |
| 20 |
|
| 21 |
/** |
| 22 |
* The type of customize control being rendered. |
| 23 |
* |
| 24 |
* @since 1.0.17 |
| 25 |
* @access public |
| 26 |
* @var string |
| 27 |
*/ |
| 28 |
public $thumbnail; |
| 29 |
|
| 30 |
/** |
| 31 |
* Promotion text for <the> Controler</the>. |
| 32 |
* |
| 33 |
* @since 1.0.17 |
| 34 |
* @access public |
| 35 |
* @var string |
| 36 |
*/ |
| 37 |
public $promo_text; |
| 38 |
|
| 39 |
/** |
| 40 |
* Promotion link for the Controler |
| 41 |
* |
| 42 |
* @since 1.0.17 |
| 43 |
* @access public |
| 44 |
* @var string |
| 45 |
*/ |
| 46 |
public $link; |
| 47 |
|
| 48 |
/** |
| 49 |
* Enqueue scripts/styles. |
| 50 |
* |
| 51 |
* @since 1.0.17 |
| 52 |
* @access public |
| 53 |
* @return void |
| 54 |
*/ |
| 55 |
public function enqueue() { |
| 56 |
// wp_enqueue_script( 'jt-customize-controls', plugins_url( '/customize-controls.js' , __FILE__ ), array( 'jquery' ) ); |
| 57 |
// wp_enqueue_script( 'jquery-ui-button' ); |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Displays the control content. |
| 62 |
* |
| 63 |
* @since 1.0.17 |
| 64 |
* @access public |
| 65 |
* @return void |
| 66 |
*/ |
| 67 |
public function render_content() { |
| 68 |
?> |
| 69 |
|
| 70 |
<span class="customize-control-title"> |
| 71 |
<?php echo esc_attr( $this->label ); ?> |
| 72 |
<?php if ( ! empty( $this->description ) ) : ?> |
| 73 |
<span class="description customize-control-description"><?php echo esc_html( $this->description ); ?></span> |
| 74 |
<?php endif; ?> |
| 75 |
</span> |
| 76 |
|
| 77 |
|
| 78 |
<div id="input_<?php echo $this->id; ?>" class="image"> |
| 79 |
|
| 80 |
<div class="loginpress_promo_thumbnail"> |
| 81 |
<a href="<?php echo esc_url( $this->link );?>" target="_blank"> |
| 82 |
<div class="customizer-promo-overlay"> |
| 83 |
<span class="customizer-promo-text"><?php echo esc_html( $this->promo_text ); ?></span> |
| 84 |
</div> |
| 85 |
<img src="<?php echo esc_url( $this->thumbnail ); ?>" alt="<?php echo esc_attr( $this->id ); ?>" title="<?php echo esc_attr( $this->id ); ?>"> |
| 86 |
</a> |
| 87 |
</div> <!-- .loginpress_promo_thumbnail --> |
| 88 |
|
| 89 |
</div> |
| 90 |
|
| 91 |
<?php } |
| 92 |
|
| 93 |
|
| 94 |
} |
| 95 |
|
| 96 |
if ( !function_exists( 'loginpress_promo_control_css' ) ) { |
| 97 |
function loginpress_promo_control_css() { |
| 98 |
?> |
| 99 |
<style> |
| 100 |
.loginpress_promo_thumbnail a{ |
| 101 |
display: inline-block; |
| 102 |
position: relative; |
| 103 |
border:5px solid transparent; |
| 104 |
} |
| 105 |
.loginpress_promo_thumbnail a .customizer-promo-overlay{ |
| 106 |
position: absolute; |
| 107 |
top: 0; |
| 108 |
left: 0; |
| 109 |
width: 100%; |
| 110 |
height: 100%; |
| 111 |
background: rgba(204, 204, 204, 0.8); |
| 112 |
content: ''; |
| 113 |
-webkit-transition: all 0.2s ease-in-out; |
| 114 |
-moz-transition: all 0.2s ease-in-out; |
| 115 |
-ms-transition: all 0.2s ease-in-out; |
| 116 |
transition: all 0.2s ease-in-out; |
| 117 |
opacity: 0; |
| 118 |
visibility: hidden; |
| 119 |
-webkit-transform: scale(.5); |
| 120 |
-moz-transform: scale(.5); |
| 121 |
-ms-transform: scale(.5); |
| 122 |
transform: scale(.5); |
| 123 |
} |
| 124 |
.customizer-promo-text{ |
| 125 |
line-height:1.2; |
| 126 |
position: absolute; |
| 127 |
top: 50%; |
| 128 |
left: 50%; |
| 129 |
-webkit-transform:translate(-50%, -50%); |
| 130 |
transform:translate(-50%, -50%); |
| 131 |
width: 100%; |
| 132 |
font-size: 25px; |
| 133 |
color: #000; |
| 134 |
z-index: 100; |
| 135 |
text-align: center; |
| 136 |
opacity: 0; |
| 137 |
} |
| 138 |
.loginpress_promo_thumbnail a:hover{ |
| 139 |
border-color: #ccc; |
| 140 |
} |
| 141 |
.loginpress_promo_thumbnail a:hover .customizer-promo-text{ |
| 142 |
opacity: 1; |
| 143 |
} |
| 144 |
.loginpress_promo_thumbnail a:hover .customizer-promo-overlay{ |
| 145 |
opacity: 1; |
| 146 |
visibility: visible; |
| 147 |
-webkit-transform: scale(1); |
| 148 |
-moz-transform: scale(1); |
| 149 |
-ms-transform: scale(1); |
| 150 |
transform: scale(1); |
| 151 |
} |
| 152 |
</style> |
| 153 |
<?php |
| 154 |
} |
| 155 |
} |
| 156 |
add_action( 'customize_controls_print_styles', 'loginpress_promo_control_css' ); |
| 157 |
?> |
| 158 |
|