| 1 |
<?php |
| 2 |
namespace ULTP\blocks; |
| 3 |
|
| 4 |
defined('ABSPATH') || exit; |
| 5 |
|
| 6 |
class Archive_Title{ |
| 7 |
public function __construct() { |
| 8 |
add_action('init', array($this, 'register')); |
| 9 |
} |
| 10 |
public function get_attributes($default = false){ |
| 11 |
|
| 12 |
$attributes = array( |
| 13 |
'blockId' => [ |
| 14 |
'type' => 'string', |
| 15 |
'default' => '', |
| 16 |
], |
| 17 |
|
| 18 |
//-------------------------- |
| 19 |
// Layout |
| 20 |
//-------------------------- |
| 21 |
'layout' => [ |
| 22 |
'type' => 'string', |
| 23 |
'default' => '1', |
| 24 |
], |
| 25 |
'contentAlign' => [ |
| 26 |
'type' => 'string', |
| 27 |
'default' => "left", |
| 28 |
'style' => [ |
| 29 |
(object)[ |
| 30 |
'depends' => [ |
| 31 |
(object)['key'=>'contentAlign','condition'=>'==','value'=>'left'], |
| 32 |
], |
| 33 |
'selector'=>'{{ULTP}} .ultp-block-archive-title { text-align:{{contentAlign}}; }' |
| 34 |
], |
| 35 |
(object)[ |
| 36 |
'depends' => [ |
| 37 |
(object)['key'=>'contentAlign','condition'=>'==','value'=>'center'], |
| 38 |
], |
| 39 |
'selector'=>'{{ULTP}} .ultp-block-archive-title { text-align:{{contentAlign}}; }' |
| 40 |
], |
| 41 |
(object)[ |
| 42 |
'depends' => [ |
| 43 |
(object)['key'=>'contentAlign','condition'=>'==','value'=>'right'], |
| 44 |
], |
| 45 |
'selector'=>'{{ULTP}} .ultp-block-archive-title { text-align:{{contentAlign}}; }' |
| 46 |
], |
| 47 |
], |
| 48 |
], |
| 49 |
//-------------------------- |
| 50 |
// General Settings |
| 51 |
//-------------------------- |
| 52 |
'titleShow' => [ |
| 53 |
'type' => 'boolean', |
| 54 |
'default' => true, |
| 55 |
], |
| 56 |
'excerptShow' => [ |
| 57 |
'type' => 'boolean', |
| 58 |
'default' => true |
| 59 |
], |
| 60 |
'prefixShow' => [ |
| 61 |
'type' => 'boolean', |
| 62 |
'default' => false, |
| 63 |
], |
| 64 |
'showImage' => [ |
| 65 |
'type' => 'boolean', |
| 66 |
'default' => false, |
| 67 |
], |
| 68 |
|
| 69 |
//-------------------------- |
| 70 |
// Title Setting/Style |
| 71 |
//-------------------------- |
| 72 |
'titleTag' => [ |
| 73 |
'type' => 'string', |
| 74 |
'default' => 'h1', |
| 75 |
], |
| 76 |
'customTaxTitleColor' => [ |
| 77 |
'type' => 'boolean', |
| 78 |
'default' => false, |
| 79 |
], |
| 80 |
'seperatorTaxTitleLink' => [ |
| 81 |
'type' => 'string', |
| 82 |
'default' => admin_url( 'edit-tags.php?taxonomy=category' ), |
| 83 |
'style' => [ |
| 84 |
(object)[ |
| 85 |
'depends' => [ |
| 86 |
(object)['key'=>'customTaxTitleColor','condition'=>'==','value'=>true], |
| 87 |
] |
| 88 |
] |
| 89 |
] |
| 90 |
], |
| 91 |
'titleColor' => [ |
| 92 |
'type' => 'string', |
| 93 |
'default' => '', |
| 94 |
'style' => [ |
| 95 |
(object)[ |
| 96 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-name { color:{{titleColor}}; }' |
| 97 |
], |
| 98 |
(object)[ |
| 99 |
'depends' => [ |
| 100 |
(object)['key'=>'customTaxTitleColor','condition'=>'==','value'=>false], |
| 101 |
], |
| 102 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-name { color:{{titleColor}}; }' |
| 103 |
], |
| 104 |
|
| 105 |
], |
| 106 |
], |
| 107 |
'titleTypo' => [ |
| 108 |
'type' => 'object', |
| 109 |
'default' => (object)['openTypography'=>1,'size'=>(object)['lg'=>'28', 'unit'=>'px'], 'spacing'=>(object)[ 'lg'=>'0', 'unit'=>'px'], 'height'=>(object)['lg'=>'32', 'unit'=>'px'],'transform' => '', 'decoration'=>'none','family'=>'','weight'=>''], |
| 110 |
'style' => [ |
| 111 |
(object)[ |
| 112 |
'depends' => [ |
| 113 |
(object)['key'=>'titleShow','condition'=>'==','value'=>true], |
| 114 |
], |
| 115 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-name' |
| 116 |
], |
| 117 |
], |
| 118 |
], |
| 119 |
'titlePadding' => [ |
| 120 |
'type' => 'object', |
| 121 |
'default' => (object)['lg'=>(object)['unit'=>'px']], |
| 122 |
'style' => [ |
| 123 |
(object)[ |
| 124 |
'depends' => [ |
| 125 |
(object)['key'=>'titleShow','condition'=>'==','value'=>true], |
| 126 |
], |
| 127 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-name { padding:{{titlePadding}}; }' |
| 128 |
], |
| 129 |
], |
| 130 |
], |
| 131 |
|
| 132 |
//-------------------------- |
| 133 |
// Content Setting/Style |
| 134 |
//-------------------------- |
| 135 |
'excerptColor' => [ |
| 136 |
'type' => 'string', |
| 137 |
'default' => '', |
| 138 |
'style' => [ |
| 139 |
(object)[ |
| 140 |
'depends' => [ |
| 141 |
(object)['key'=>'excerptShow','condition'=>'==','value'=>true], |
| 142 |
], |
| 143 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-desc { color:{{excerptColor}}; }' |
| 144 |
], |
| 145 |
], |
| 146 |
], |
| 147 |
'excerptTypo' => [ |
| 148 |
'type' => 'object', |
| 149 |
'default' => (object)['openTypography' => 1,'size' => (object)['lg' =>14, 'unit' =>'px'],'height' => (object)['lg' =>'22', 'unit' =>'px'], 'decoration' => 'none','family'=>''], |
| 150 |
'style' => [ |
| 151 |
(object)[ |
| 152 |
'depends' => [ |
| 153 |
(object)['key'=>'excerptShow','condition'=>'==','value'=>true], |
| 154 |
], |
| 155 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-desc' |
| 156 |
], |
| 157 |
], |
| 158 |
], |
| 159 |
'excerptPadding' => [ |
| 160 |
'type' => 'object', |
| 161 |
'default' => (object)['lg' =>(object)['top' => '0','bottom' => '', 'unit' =>'px']], |
| 162 |
'style' => [ |
| 163 |
(object)[ |
| 164 |
'depends' => [ |
| 165 |
(object)['key'=>'excerptShow','condition'=>'==','value'=>true], |
| 166 |
], |
| 167 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-desc { padding: {{excerptPadding}}; }' |
| 168 |
], |
| 169 |
], |
| 170 |
], |
| 171 |
|
| 172 |
//-------------------------- |
| 173 |
// Prefix Setting/Style |
| 174 |
//-------------------------- |
| 175 |
'prefixText' => [ |
| 176 |
'type' => 'string', |
| 177 |
'default' => 'Sample Prefix Text', |
| 178 |
], |
| 179 |
'prefixColor' => [ |
| 180 |
'type' => 'string', |
| 181 |
'default' => '', |
| 182 |
'style' => [ |
| 183 |
(object)[ |
| 184 |
'depends' => [ |
| 185 |
(object)['key'=>'prefixShow','condition'=>'==','value'=>true], |
| 186 |
], |
| 187 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-prefix { color:{{prefixColor}}; }' |
| 188 |
], |
| 189 |
], |
| 190 |
], |
| 191 |
'prefixTypo' => [ |
| 192 |
'type' => 'object', |
| 193 |
'default' => (object)['openTypography'=>1,'size'=>(object)['lg'=>'', 'unit'=>'px'], 'spacing'=>(object)[ 'lg'=>'0', 'unit'=>'px'], 'height'=>(object)['lg'=>'', 'unit'=>'px'],'transform' => '', 'decoration'=>'none','family'=>'','weight'=>''], |
| 194 |
'style' => [ |
| 195 |
(object)[ |
| 196 |
'depends' => [ |
| 197 |
(object)['key'=>'prefixShow','condition'=>'==','value'=>true], |
| 198 |
], |
| 199 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-prefix' |
| 200 |
], |
| 201 |
], |
| 202 |
], |
| 203 |
'prefixPadding' => [ |
| 204 |
'type' => 'object', |
| 205 |
'default' => (object)['lg'=>(object)['top'=>10,'bottom'=>5, 'unit'=>'px']], |
| 206 |
'style' => [ |
| 207 |
(object)[ |
| 208 |
'depends' => [ |
| 209 |
(object)['key'=>'prefixShow','condition'=>'==','value'=>true], |
| 210 |
], |
| 211 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-prefix { padding:{{prefixPadding}}; }' |
| 212 |
], |
| 213 |
], |
| 214 |
], |
| 215 |
|
| 216 |
|
| 217 |
//-------------------------- |
| 218 |
// Image Setting/Style |
| 219 |
//-------------------------- |
| 220 |
'imgWidth' => [ |
| 221 |
'type' => 'object', |
| 222 |
'default' => (object)['lg' =>'', 'unit' =>'%'], |
| 223 |
'style' => [ |
| 224 |
(object)[ |
| 225 |
'depends' => [ |
| 226 |
(object)['key'=>'layout','condition'=>'==','value'=>['1']], |
| 227 |
], |
| 228 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-image { max-width: {{imgWidth}}; }' |
| 229 |
], |
| 230 |
], |
| 231 |
], |
| 232 |
'imgHeight' => [ |
| 233 |
'type' => 'object', |
| 234 |
'default' => (object)['lg' =>'', 'unit' =>'px'], |
| 235 |
'style' => [ |
| 236 |
(object)[ |
| 237 |
'depends' => [ |
| 238 |
(object)['key'=>'layout','condition'=>'==','value'=>['1']], |
| 239 |
], |
| 240 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-image {object-fit: cover; height: {{imgHeight}}; }' |
| 241 |
], |
| 242 |
], |
| 243 |
], |
| 244 |
'imgSpacing' => [ |
| 245 |
'type' => 'object', |
| 246 |
'default' => (object)['lg'=>'10'], |
| 247 |
'style' => [ |
| 248 |
(object)[ |
| 249 |
'depends' => [ |
| 250 |
(object)['key'=>'layout','condition'=>'==','value'=>['1']], |
| 251 |
], |
| 252 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-image { margin-bottom: {{imgSpacing}}px; }' |
| 253 |
], |
| 254 |
], |
| 255 |
], |
| 256 |
|
| 257 |
//-------------------------- |
| 258 |
// Custom Wrapper Style |
| 259 |
//-------------------------- |
| 260 |
'customTaxColor' => [ |
| 261 |
'type' => 'boolean', |
| 262 |
'default' => false, |
| 263 |
], |
| 264 |
'seperatorTaxLink' => [ |
| 265 |
'type' => 'string', |
| 266 |
'default' => admin_url( 'edit-tags.php?taxonomy=category' ), |
| 267 |
'style' => [ |
| 268 |
(object)[ |
| 269 |
'depends' => [ |
| 270 |
(object)['key'=>'customTaxColor','condition'=>'==','value'=>true], |
| 271 |
] |
| 272 |
] |
| 273 |
] |
| 274 |
], |
| 275 |
'TaxAnimation' => [ |
| 276 |
'type' => 'string', |
| 277 |
'default' => 'none' |
| 278 |
], |
| 279 |
|
| 280 |
'TaxWrapBg' => [ |
| 281 |
'type' => 'string', |
| 282 |
'default' => '', |
| 283 |
'style' => [ |
| 284 |
(object)[ |
| 285 |
'depends' => [ |
| 286 |
// (object)['key'=>'layout','condition'=>'==','value'=>[2, 3, 6, 7, 8]], |
| 287 |
(object)['key'=>'customTaxColor','condition'=>'!=','value'=>true], |
| 288 |
], |
| 289 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-content .ultp-archive-overlay { background:{{TaxWrapBg}}; }' |
| 290 |
], |
| 291 |
], |
| 292 |
], |
| 293 |
'TaxWrapHoverBg' => [ |
| 294 |
'type' => 'string', |
| 295 |
'style' => [ |
| 296 |
(object)[ |
| 297 |
'depends' => [ |
| 298 |
(object)['key'=>'customTaxColor','condition'=>'!=','value'=>true], |
| 299 |
], |
| 300 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-content:hover .ultp-archive-overlay { background:{{TaxWrapHoverBg}}; }' |
| 301 |
], |
| 302 |
], |
| 303 |
], |
| 304 |
'TaxWrapBorder' => [ |
| 305 |
'type' => 'object', |
| 306 |
'default' => (object)['openBorder'=>0, 'width' => (object)[ 'top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4','type' => 'solid' ], |
| 307 |
'style' => [ |
| 308 |
(object)[ |
| 309 |
'depends' => [ |
| 310 |
(object)['key'=>'layout','condition'=>'==','value'=>['2']], |
| 311 |
], |
| 312 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-content' |
| 313 |
], |
| 314 |
], |
| 315 |
], |
| 316 |
'TaxWrapHoverBorder' => [ |
| 317 |
'type' => 'object', |
| 318 |
'default' => (object)['openBorder'=>0, 'width' => (object)[ 'top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4','type' => 'solid' ], |
| 319 |
'style' => [ |
| 320 |
(object)[ |
| 321 |
'depends' => [ |
| 322 |
(object)['key'=>'layout','condition'=>'==','value'=>['2']], |
| 323 |
], |
| 324 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-content:hover' |
| 325 |
], |
| 326 |
], |
| 327 |
], |
| 328 |
'TaxWrapShadow' => [ |
| 329 |
'type' => 'object', |
| 330 |
'default' => (object)['openShadow' => 0, 'width' => (object)['top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4'], |
| 331 |
'style' => [ |
| 332 |
(object)[ |
| 333 |
'depends' => [ |
| 334 |
(object)['key'=>'layout','condition'=>'==','value'=>['2']], |
| 335 |
], |
| 336 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-content' |
| 337 |
], |
| 338 |
], |
| 339 |
], |
| 340 |
'TaxWrapHoverShadow' => [ |
| 341 |
'type' => 'object', |
| 342 |
'default' => (object)['openShadow' => 0, 'width' => (object)['top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4'], |
| 343 |
'style' => [ |
| 344 |
(object)[ |
| 345 |
'depends' => [ |
| 346 |
(object)['key'=>'layout','condition'=>'==','value'=>['2']], |
| 347 |
], |
| 348 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-content:hover' |
| 349 |
], |
| 350 |
], |
| 351 |
], |
| 352 |
'TaxWrapRadius' => [ |
| 353 |
'type' => 'object', |
| 354 |
'default' => (object)['lg' =>(object)['top' => '','bottom' => '', 'unit' =>'px']], |
| 355 |
'style' => [ |
| 356 |
(object)[ |
| 357 |
'depends' => [ |
| 358 |
(object)['key'=>'layout','condition'=>'==','value'=>['2']], |
| 359 |
], |
| 360 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-content { border-radius: {{TaxWrapRadius}}; }' |
| 361 |
], |
| 362 |
], |
| 363 |
], |
| 364 |
'TaxWrapHoverRadius' => [ |
| 365 |
'type' => 'object', |
| 366 |
'default' => (object)['lg' =>(object)['top' => '','bottom' => '', 'unit' =>'px']], |
| 367 |
'style' => [ |
| 368 |
(object)[ |
| 369 |
'depends' => [ |
| 370 |
(object)['key'=>'layout','condition'=>'==','value'=>['2']], |
| 371 |
], |
| 372 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-content:hover { border-radius: {{TaxWrapHoverRadius}}; }' |
| 373 |
], |
| 374 |
], |
| 375 |
], |
| 376 |
'customOpacityTax' => [ |
| 377 |
'type' => 'string', |
| 378 |
'default' => .6, |
| 379 |
'style' => [ |
| 380 |
(object)[ |
| 381 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-content .ultp-archive-overlay { opacity: {{customOpacityTax}}; }' |
| 382 |
], |
| 383 |
], |
| 384 |
], |
| 385 |
'customTaxOpacityHover' => [ |
| 386 |
'type' => 'string', |
| 387 |
'default' => .9, |
| 388 |
'style' => [ |
| 389 |
(object)[ |
| 390 |
'selector'=>'{{ULTP}} .ultp-taxonomy-items li a:hover .ultp-archive-overlay { opacity: {{customTaxOpacityHover}}; }' |
| 391 |
], |
| 392 |
], |
| 393 |
], |
| 394 |
'TaxWrapPadding' => [ |
| 395 |
'type' => 'object', |
| 396 |
'default' => (object)['lg' =>(object)['top' => '20','bottom' => '20','left' => '20','right' => '20', 'unit' =>'px']], |
| 397 |
'style' => [ |
| 398 |
(object)[ |
| 399 |
'depends' => [ |
| 400 |
(object)['key'=>'layout','condition'=>'==','value'=>['2']], |
| 401 |
], |
| 402 |
'selector'=>'{{ULTP}} .ultp-block-archive-title .ultp-archive-content { padding: {{TaxWrapPadding}}; }' |
| 403 |
], |
| 404 |
], |
| 405 |
], |
| 406 |
|
| 407 |
//-------------------------- |
| 408 |
// Wrapper Style |
| 409 |
//-------------------------- |
| 410 |
'wrapBg' => [ |
| 411 |
'type' => 'object', |
| 412 |
'default' => (object)['openColor' => 0, 'type' => 'color', 'color' => '#f5f5f5'], |
| 413 |
'style' => [ |
| 414 |
(object)[ |
| 415 |
'selector'=>'{{ULTP}} .ultp-block-wrapper' |
| 416 |
], |
| 417 |
], |
| 418 |
], |
| 419 |
'wrapBorder' => [ |
| 420 |
'type' => 'object', |
| 421 |
'default' => (object)['openBorder'=>0, 'width' =>(object)['top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4','type' => 'solid'], |
| 422 |
'style' => [ |
| 423 |
(object)[ |
| 424 |
'selector'=>'{{ULTP}} .ultp-block-wrapper' |
| 425 |
], |
| 426 |
], |
| 427 |
], |
| 428 |
'wrapShadow' => [ |
| 429 |
'type' => 'object', |
| 430 |
'default' => (object)['openShadow' => 0, 'width' => (object)['top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4'], |
| 431 |
'style' => [ |
| 432 |
(object)[ |
| 433 |
'selector'=>'{{ULTP}} .ultp-block-wrapper' |
| 434 |
], |
| 435 |
], |
| 436 |
], |
| 437 |
'wrapRadius' => [ |
| 438 |
'type' => 'object', |
| 439 |
'default' => (object)['lg' =>'', 'unit' =>'px'], |
| 440 |
'style' => [ |
| 441 |
(object)[ |
| 442 |
'selector'=>'{{ULTP}} .ultp-block-wrapper { border-radius:{{wrapRadius}}; }' |
| 443 |
], |
| 444 |
], |
| 445 |
], |
| 446 |
'wrapHoverBackground' => [ |
| 447 |
'type' => 'object', |
| 448 |
'default' => (object)['openColor' => 0, 'type' => 'color', 'color' => '#037fff'], |
| 449 |
'style' => [ |
| 450 |
(object)[ |
| 451 |
'selector'=>'{{ULTP}} .ultp-block-wrapper:hover' |
| 452 |
], |
| 453 |
], |
| 454 |
], |
| 455 |
'wrapHoverBorder' => [ |
| 456 |
'type' => 'object', |
| 457 |
'default' => (object)['openBorder'=>0, 'width' => (object)['top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4','type' => 'solid'], |
| 458 |
'style' => [ |
| 459 |
(object)[ |
| 460 |
'selector'=>'{{ULTP}} .ultp-block-wrapper:hover' |
| 461 |
], |
| 462 |
], |
| 463 |
], |
| 464 |
'wrapHoverRadius' => [ |
| 465 |
'type' => 'object', |
| 466 |
'default' => (object)['lg' =>'', 'unit' =>'px'], |
| 467 |
'style' => [ |
| 468 |
(object)[ |
| 469 |
'selector'=>'{{ULTP}} .ultp-block-wrapper:hover { border-radius:{{wrapHoverRadius}}; }' |
| 470 |
], |
| 471 |
], |
| 472 |
], |
| 473 |
'wrapHoverShadow' => [ |
| 474 |
'type' => 'object', |
| 475 |
'default' => (object)['openShadow' => 0, 'width' => (object)['top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4'], |
| 476 |
'style' => [ |
| 477 |
(object)[ |
| 478 |
'selector'=>'{{ULTP}} .ultp-block-wrapper:hover' |
| 479 |
], |
| 480 |
], |
| 481 |
], |
| 482 |
'wrapMargin' => [ |
| 483 |
'type' => 'object', |
| 484 |
'default' => (object)['lg' =>(object)['top' => '','bottom' => '', 'unit' =>'px']], |
| 485 |
'style' => [ |
| 486 |
(object)[ |
| 487 |
'selector'=>'{{ULTP}} .ultp-block-wrapper { margin:{{wrapMargin}}; }' |
| 488 |
], |
| 489 |
], |
| 490 |
], |
| 491 |
'wrapOuterPadding' => [ |
| 492 |
'type' => 'object', |
| 493 |
'default' => (object)['lg' =>(object)['top' => '','bottom' => '','left' => '', 'right' => '', 'unit' =>'px']], |
| 494 |
'style' => [ |
| 495 |
(object)[ |
| 496 |
'selector'=>'{{ULTP}} .ultp-block-wrapper { padding:{{wrapOuterPadding}}; }' |
| 497 |
], |
| 498 |
], |
| 499 |
], |
| 500 |
'advanceId' => [ |
| 501 |
'type' => 'string', |
| 502 |
'default' => '', |
| 503 |
], |
| 504 |
'advanceZindex' => [ |
| 505 |
'type' => 'number', |
| 506 |
'default' => '', |
| 507 |
'style' => [ |
| 508 |
(object)[ |
| 509 |
'selector' => '{{ULTP}} {z-index:{{advanceZindex}};}' |
| 510 |
], |
| 511 |
], |
| 512 |
], |
| 513 |
|
| 514 |
//--------------------- |
| 515 |
// Advanced > Responsive |
| 516 |
//--------------------- |
| 517 |
'hideExtraLarge' => [ |
| 518 |
'type' => 'boolean', |
| 519 |
'default' => false, |
| 520 |
'style' => [ |
| 521 |
(object)[ |
| 522 |
'selector' => '{{ULTP}} {display:none;}' |
| 523 |
], |
| 524 |
], |
| 525 |
], |
| 526 |
'hideTablet' => [ |
| 527 |
'type' => 'boolean', |
| 528 |
'default' => false, |
| 529 |
'style' => [ |
| 530 |
(object)[ |
| 531 |
'selector' => '{{ULTP}} {display:none;}' |
| 532 |
], |
| 533 |
], |
| 534 |
], |
| 535 |
'hideMobile' => [ |
| 536 |
'type' => 'boolean', |
| 537 |
'default' => false, |
| 538 |
'style' => [ |
| 539 |
(object)[ |
| 540 |
'selector' => '{{ULTP}} {display:none;}' |
| 541 |
], |
| 542 |
], |
| 543 |
], |
| 544 |
'advanceCss' => [ |
| 545 |
'type' => 'string', |
| 546 |
'default' => '', |
| 547 |
'style' => [ |
| 548 |
(object)[ |
| 549 |
'selector' => '{{ULTP}} {display:none;}' |
| 550 |
], |
| 551 |
], |
| 552 |
], |
| 553 |
); |
| 554 |
|
| 555 |
if( $default ){ |
| 556 |
$temp = array(); |
| 557 |
foreach ($attributes as $key => $value) { |
| 558 |
if( isset($value['default']) ){ |
| 559 |
$temp[$key] = $value['default']; |
| 560 |
} |
| 561 |
} |
| 562 |
return $temp; |
| 563 |
}else{ |
| 564 |
return $attributes; |
| 565 |
} |
| 566 |
} |
| 567 |
|
| 568 |
public function register() { |
| 569 |
register_block_type( 'ultimate-post/archive-title', |
| 570 |
array( |
| 571 |
'title' => __('Archive Title', 'ultimate-post'), |
| 572 |
'attributes' => $this->get_attributes(), |
| 573 |
'render_callback' => array($this, 'content') |
| 574 |
) |
| 575 |
); |
| 576 |
} |
| 577 |
|
| 578 |
public function get_data() { |
| 579 |
if (is_admin()) { |
| 580 |
// For Demonstration Purpose |
| 581 |
return [ |
| 582 |
'title' => 'Archive Title', |
| 583 |
'image' => ULTP_URL.'assets/img/builder-fallback.jpg', |
| 584 |
'desc' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam molestie aliquet molestie.', |
| 585 |
'color' => '#037fff' |
| 586 |
]; |
| 587 |
} else { |
| 588 |
if (is_archive()) { |
| 589 |
if (is_category()) { |
| 590 |
$obj = get_queried_object(); |
| 591 |
$attachment_id = get_term_meta( $obj->term_id, 'ultp_category_image', true ); |
| 592 |
return [ |
| 593 |
'title' => $obj->name, |
| 594 |
'image' => $attachment_id ? wp_get_attachment_url($attachment_id) : '', |
| 595 |
'desc' => $obj->description, |
| 596 |
'color' => get_term_meta( $obj->term_id, 'ultp_category_color', true ) |
| 597 |
]; |
| 598 |
} else if (is_tag()) { |
| 599 |
$obj = get_queried_object(); |
| 600 |
$attachment_id = get_term_meta( $obj->term_id, 'ultp_category_image', true ); |
| 601 |
return [ |
| 602 |
'title' => $obj->name, |
| 603 |
'image' => $attachment_id ? wp_get_attachment_url($attachment_id) : '', |
| 604 |
'desc' => $obj->description, |
| 605 |
'color' => get_term_meta( $obj->term_id, 'ultp_category_color', true ) |
| 606 |
]; |
| 607 |
} else if (is_date()) { |
| 608 |
$date = ''; |
| 609 |
if ( is_year() ) { |
| 610 |
$date = get_the_date('Y'); |
| 611 |
} else if ( is_month() ) { |
| 612 |
$date = get_the_date('F Y'); |
| 613 |
} else if ( is_day() ) { |
| 614 |
$date = get_the_date('F j, Y'); |
| 615 |
} |
| 616 |
return [ |
| 617 |
'title' => $date, |
| 618 |
'image' => '', |
| 619 |
'desc' => '', |
| 620 |
'color' => '' |
| 621 |
]; |
| 622 |
} else if (is_author()) { |
| 623 |
return [ |
| 624 |
'title' => get_the_author_meta( 'display_name' ), |
| 625 |
'image' => get_avatar_url( get_the_author_meta( 'ID' ) ), |
| 626 |
'desc' => get_the_author_meta( 'user_email' ), |
| 627 |
'color' => '' |
| 628 |
]; |
| 629 |
} else if (is_tax()) { |
| 630 |
$obj = get_queried_object(); |
| 631 |
$attachment_id = get_term_meta( $obj->term_id, 'ultp_category_image', true ); |
| 632 |
return [ |
| 633 |
'title' => $obj->name, |
| 634 |
'image' => $attachment_id ? wp_get_attachment_url($attachment_id) : '', |
| 635 |
'desc' => $obj->description, |
| 636 |
'color' => get_term_meta( $obj->term_id, 'ultp_category_color', true ) |
| 637 |
]; |
| 638 |
} |
| 639 |
} else if (is_search()) { |
| 640 |
return [ |
| 641 |
'title' => get_search_query(), |
| 642 |
'image' => '', |
| 643 |
'desc' => '', |
| 644 |
'color' => '' |
| 645 |
]; |
| 646 |
} |
| 647 |
return ['title' => '', 'image' => '', 'desc' => '']; |
| 648 |
} |
| 649 |
} |
| 650 |
|
| 651 |
|
| 652 |
public function content($attr, $noAjax) { |
| 653 |
|
| 654 |
// Dummy |
| 655 |
$data = $this->get_data(); |
| 656 |
$wraper_before = $wraper_after = $post_loop = ''; |
| 657 |
$block_name = 'archive-title'; |
| 658 |
|
| 659 |
$wraper_before .= '<div '.($attr['advanceId']?'id="'.$attr['advanceId'].'" ':'').' class="wp-block-ultimate-post-'.$block_name.' ultp-block-'.$attr["blockId"].''.(isset($attr["align"])? ' align' .$attr["align"]:'').''.(isset($attr["className"])?' '.$attr["className"]:'').'">'; |
| 660 |
$wraper_before .= '<div class="ultp-block-wrapper">'; |
| 661 |
$wraper_before .= '<div class="ultp-block-archive-title ultp-archive-layout-'.$attr['layout'].'">'; |
| 662 |
|
| 663 |
$style = $attr['layout'] == '2' ? ($data['image'] ? 'style="background-image: url('.$data['image'].')' : 'style="background-color:'.($data['color'] ? $data['color'] : '#28303d')).'"' : ''; |
| 664 |
$prefix = ($attr['prefixShow'] && $attr['prefixText']) ? '<span class="ultp-archive-prefix">'.$attr['prefixText'].'</span> ' : ''; |
| 665 |
|
| 666 |
$name = ($attr['titleShow'] && $data['title']) ? '<'.$attr['titleTag'].' class="ultp-archive-name" '.( ( $data['color'] && $attr['customTaxTitleColor'] ) ? 'style="color: '.$data['color'].'"' : '').'>'.$prefix.$data['title'].'</'.$attr['titleTag'].'>' : ''; |
| 667 |
|
| 668 |
$excerpt = ($attr['excerptShow'] && $data['desc']) ? '<div class="ultp-archive-desc">'.$data['desc'].'</div>' : ''; |
| 669 |
|
| 670 |
// Prefix |
| 671 |
switch ($attr['layout']) { |
| 672 |
case 1: |
| 673 |
$img = ($attr['showImage'] && $data['image']) ? '<img class="ultp-archive-image" src="'.$data['image'].'" alt="'.$data['title'].'"/>' : ''; |
| 674 |
$post_loop .= $img.$name.$excerpt; |
| 675 |
break; |
| 676 |
case 2: |
| 677 |
$style_overlay = $attr['customTaxColor'] ? 'style="background-color: '.$data['color'].'"' : ''; |
| 678 |
|
| 679 |
$post_loop .= '<div class="ultp-archive-content" '.$style.'><div class="ultp-archive-overlay" '.$style_overlay.'></div>'.$name.$excerpt.'</div>'; |
| 680 |
break; |
| 681 |
} |
| 682 |
|
| 683 |
$wraper_after .= '</div>'; |
| 684 |
$wraper_after .= '</div>'; |
| 685 |
$wraper_after .= '</div>'; |
| 686 |
|
| 687 |
return $wraper_before.$post_loop.$wraper_after; |
| 688 |
} |
| 689 |
|
| 690 |
} |