Changeset 1921678
- Timestamp:
- 08/08/2018 02:26:30 PM (8 years ago)
- Location:
- oi-yamaps/trunk
- Files:
-
- 4 edited
-
Readme.md (modified) (1 diff)
-
include/oi-nput.php (modified) (33 diffs)
-
oi-yamaps.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
oi-yamaps/trunk/Readme.md
r1914834 r1921678 47 47 ## Changelog 48 48 49 ### 3.1.9 (08.08.2018) 50 * fix: plugin header correction; 49 51 ### 3.1.8 (25.07.2018) 50 52 * fix: custom placemark special attribut added; -
oi-yamaps/trunk/include/oi-nput.php
r1885266 r1921678 1 1 <?php 2 /* 3 Plugin Name: Oi Nput4 Plugin URI: http://oiplug.com5 Description: Plugin for making HTML forms via array.6 Version: 1.4 7 Author: Alexei Isaenko8 Author URI: http://sh14.ru9 License: GPL210 Tags: input, textarea, select, option, password, hidden, checkbox, radiobox11 GitHub Plugin URI: https://github.com/sh14/oi-nput12 */2 /** 3 * Plugin Name: Oi Nput 4 * Plugin URI: http://oiplug.com 5 * Description: Plugin for making HTML forms via array. 6 * Version: 1.5 7 * Author: Alexei Isaenko 8 * Author URI: http://sh14.ru 9 * License: GPL2 10 * Tags: input, textarea, select, option, password, hidden, checkbox, radiobox 11 * GitHub Plugin URI: https://github.com/sh14/oi-nput 12 */ 13 13 14 14 if ( ! function_exists( 'esc_attr' ) ) { … … 95 95 if ( ! empty( $prefix ) ) { 96 96 // формирование и добавление атрибута в массив 97 $data[] = $prefix .'-'. $key . '="' . $value . '"';97 $data[] =$prefix . '-'. $key . '="' . $value . '"'; 98 98 }else{ 99 // формирование и добавление атрибута в массив100 $data[] = $key . '="' . $value . '"';99 // формирование и добавление атрибутав массив 100 $data[] = $key . '="' . $value . '"'; 101 101 } 102 102 } else { 103 103 $data[] = attributes_to_string( $value, $key ); 104 104 } 105 106 105 } 107 106 … … 133 132 // проход по всем атрибутам 134 133 foreach ( $atts as $key => $value ) { 134 if ( is_numeric( $value ) || is_bool( $value ) ) { 135 $value .= ''; 136 } 135 137 if ( is_string( $value ) ) { 136 138 // замена псевдопременной ее значением … … 146 148 147 149 if ( ! function_exists( 'oinput' ) ) { 148 149 /*function oinput_array_to_string( $array ) {150 if ( is_array( $array ) && ! empty( $array ) ) {151 foreach ( $array as $key => $value ) {152 153 }154 }155 156 return $array;157 }*/158 150 159 151 /* … … 185 177 186 178 // если значение не пустое и оно не массив 187 if ( isset( $value ) && ! is_array( $value ) && $value != '') {179 if ( isset( $value ) && ! is_array( $value ) && '' !== $value ) { 188 180 189 181 // делается эскейп для вывода как атрибута … … 243 235 244 236 // exit if don't need to publish that field 245 if ( $atts['published'] == false) {237 if ( false === $atts['published'] ) { 246 238 return false; 247 239 } … … 260 252 261 253 // если тип поля не select и переменная является строкой 262 if ( $field_type != 'select'&& is_string( $atts['value'] ) ) {254 if ( 'select' !== $field_type && is_string( $atts['value'] ) ) { 263 255 // определение новой переменной с эскейпом 264 256 $field_value = esc_attr( $atts['value'] ); … … 271 263 } 272 264 273 if ( $atts['name'] || $field_type == 'submit' || $field_type == 'button' || $field_type == 'html') {265 if ( $atts['name'] || 'submit' === $field_type || 'button' === $field_type || 'html' === $field_type ) { 274 266 if ( empty( $atts['id'] ) ) { 275 267 $atts['id'] = $atts['name']; … … 287 279 288 280 // list of labels 289 $attributes = array( 'before', 'after', 'label', ); 281 $attributes = array( 282 'before', 283 'after', 284 'label', 285 ); 286 290 287 foreach ( $attributes as $key ) { 291 288 if ( ! empty( $atts[ $key ] ) && ! in_array( $atts['type'], array( 'checkbox', 'radio' ) ) ) { … … 295 292 296 293 // list of boolean attributes 297 $attributes = array( 'checked', 'multiple', 'readonly', 'disabled', 'required', ); 294 $attributes = array( 295 'checked', 296 'multiple', 297 'readonly', 298 'disabled', 299 'required', 300 ); 301 298 302 foreach ( $attributes as $key ) { 299 if ( $atts[ $key ] == true) {303 if ( true === $atts[ $key ] ) { 300 304 $atts[ $key ] = ' ' . esc_attr( $key ) . '="' . esc_attr( $key ) . '"'; 301 305 } else { … … 305 309 306 310 // list of boolean non pair attributes 307 $attributes = array( 'autofocus', ); 311 $attributes = array( 312 'autofocus', 313 ); 314 308 315 foreach ( $attributes as $key ) { 309 if ( $atts[ $key ] == true) {316 if ( true === $atts[ $key ] ) { 310 317 $atts[ $key ] = ' ' . esc_attr( $key ); 311 318 } else { … … 314 321 } 315 322 316 if ( $atts['autofocus_at_end'] == true) {323 if ( true === $atts['autofocus_at_end'] ) { 317 324 $atts['autofocus_at_end'] = ' onfocus="this.value = this.value;"'; 318 325 } else { … … 320 327 } 321 328 322 if ( $field_type != 'option') {329 if ( 'option' !== $field_type ) { 323 330 // list of attributes 324 331 $attributes = array( … … 341 348 if ( is_array( $atts[ $key ] ) ) { 342 349 343 if ( $key == 'class') {350 if ( 'class' === $key ) { 344 351 345 352 // формирование строки, содержащей классы … … 348 355 349 356 // если проверяется стиль 350 if ( $key == 'style') {357 if ( 'style' === $key ) { 351 358 352 359 // если атрибут что-то содержит … … 367 374 } 368 375 // если атрибут data 369 } else if ( $key == 'data') {376 } elseif ( 'data' === $key ) { 370 377 371 378 // если содержимое что-то содержит … … 375 382 $atts[ $key ] = attributes_to_string( $atts[ $key ], $key ); 376 383 } 377 378 } else if ( $key == 'attributes' ) { 384 } elseif ( 'attributes' === $key ) { 385 379 386 // если содержимое что-то содержит 380 387 if ( ! empty( $atts[ $key ] ) ) { … … 386 393 } 387 394 } else { 388 if ( $key == 'data') {395 if ( 'data' === $key ) { 389 396 $atts[ $key ] = ' ' . implode( ' ', $atts[ $key ] ); 390 397 } else { … … 408 415 }*/ 409 416 410 if ( $field_type != 'option' ) { 417 if ( 'option' !== $field_type ) { 418 411 419 // формирование элемента 412 $atts['attributes'] = $atts['placeholder'] . 413 $atts['style'] . 414 $atts['checked'] . 415 $atts['multiple'] . 416 $atts['readonly'] . 417 $atts['disabled'] . 418 $atts['required'] . 419 $atts['autofocus'] . 420 $atts['autofocus_at_end'] . 421 $atts['data'] . 422 $atts['attributes'] . 423 ''; 420 $atts['attributes'] = $atts['placeholder'] 421 . $atts['style'] 422 . $atts['checked'] 423 . $atts['multiple'] 424 . $atts['readonly'] 425 . $atts['disabled'] 426 . $atts['required'] 427 . $atts['autofocus'] 428 . $atts['autofocus_at_end'] 429 . $atts['data'] 430 . $atts['attributes']; 424 431 } 425 432 } 426 427 433 428 434 switch ( $field_type ) { … … 476 482 $out = ''; 477 483 if ( ! empty( $atts['name'] ) && is_array( $atts['name'] ) ) { 478 foreach ( $atts['name'] as $k => $v ) {484 foreach ( (array) $atts['name'] as $k => $v ) { 479 485 480 486 // указание, что элемент пока не является выбранным … … 514 520 break; 515 521 case 'radio': 516 if ( ! empty( $field_value ) ) // if we have a value 517 { 518 $atts['attributes'] .= ' checked="checked"'; // it means that that radio was checked 522 // if we have a value 523 if ( ! empty( $field_value ) ) { 524 // it means that that radio was checked 525 $atts['attributes'] .= ' checked="checked"'; 519 526 } 520 527 $out = '<' . $tag . $atts['class'] . $atts['type'] . $atts['id'] . $atts['name'] . $atts['attributes'] . $atts['value'] . ' />'; … … 596 603 597 604 // если не указано, что метод передачи POST 598 if ( $atts['method'] != 'post') {605 if ( 'post' !== $atts['method'] ) { 599 606 // устанавливается метод передачи GET 600 607 $atts['method'] = 'get'; 601 608 } 609 602 610 // trim all none boolean data 603 611 if ( ! empty( $atts ) ) { … … 611 619 612 620 // список атрибутов, которые надо сформировать в правиьном виде: атрибут="значение" 613 $attributes = array( 'id', 'name', 'method', 'action', ); 621 $attributes = array( 622 'id', 623 'name', 624 'method', 625 'action', 626 ); 614 627 615 628 // проход по списку атрибутов … … 625 638 } 626 639 627 if ( $atts['form'] == true) {640 if ( true === $atts['form'] ) { 628 641 $out = '<form ' . $atts['attributes'] . '>' . $out . '</form>'; 629 642 } 630 if ( $atts['echo'] == true) {643 if ( true === $atts['echo'] ) { 631 644 echo $out; 632 645 } … … 650 663 $template = str_replace( '%' . $key . '%', $value, $template ); 651 664 } 652 653 665 } 654 666 … … 676 688 * 677 689 * // bem array 678 * $user_links = get_html( array(690 * $user_links = get_html( [ 679 691 * 'tag' => 'div', 680 * 'atts' => array(692 * 'atts' => [ 681 693 * 'class' => '&__contacts', 682 * ),683 * 'content' => array(684 * array(694 * ], 695 * 'content' => [ 696 * [ 685 697 * 'tag' => 'h3', 686 * 'atts' => array('class' => '&__contacts-title',),698 * 'atts' => ['class' => '&__contacts-title',], 687 699 * 'content' => __( 'Bio' ), 688 * ),689 * array(700 * ], 701 * [ 690 702 * 'tag' => 'ul', 691 * 'atts' => array('class' => '&__contacts-list',),703 * 'atts' => ['class' => '&__contacts-list',], 692 704 * 'content' => implode( "\n", $user_links ), 693 * ),694 * ),695 * ), 'profile' );705 * ], 706 * ], 707 * ], 'profile' ); 696 708 * 697 709 * @param $atts … … 701 713 */ 702 714 function get_html( $atts, $base_class = '' ) { 703 $atts = shortcode_atts( array(715 $atts = shortcode_atts( [ 704 716 'tag' => 'div', 705 'atts' => array(717 'atts' => [ 706 718 'class' => '&', 707 ),719 ], 708 720 'content' => '', 709 ), $atts );710 711 $mono = array(721 ], $atts ); 722 723 $mono = [ 712 724 'br', 713 725 'hr', … … 716 728 'link', 717 729 'img', 718 );730 ]; 719 731 $out = ''; 720 $object = array();732 $object = []; 721 733 722 734 // перебор содержимого массива … … 748 760 // если значение является массивом 749 761 if ( is_array( $value ) ) { 750 $attributes = array();762 $attributes = []; 751 763 752 764 // атрибуты выстраиваются в строку … … 770 782 break; 771 783 case 'content': 772 773 784 // если элемент является массивом, вероятно это описание вложенного элемента или набора вложений 774 785 if ( is_array( $value ) ) { 775 786 776 787 foreach ( $value as $index => $val ) { 777 pr( $val );788 //pr( $val ); 778 789 $object[ $key ][] = get_html( $value, $base_class ); 779 790 } … … 792 803 793 804 if ( empty( $atts['atts'] ) ) { 794 $atts['atts'] = array();805 $atts['atts'] = []; 795 806 } 796 807 // перебор элементов и дописывание закрывающих частей … … 816 827 817 828 // порядок составления элементов 818 $order = array(829 $order = [ 819 830 'tag', 820 831 'atts', 821 832 'content', 822 833 'end_tag', 823 );834 ]; 824 835 foreach ( $order as $key ) { 825 836 if ( ! empty( $object[ $key ] ) ) { 826 837 $out .= implode( '', $object[ $key ] ); 827 838 } 828 829 839 } 830 840 … … 832 842 } 833 843 834 // eof 844 // eof; -
oi-yamaps/trunk/oi-yamaps.php
r1914834 r1921678 1 1 <?php 2 /* 3 Plugin Name: Oi Yandex.Maps for WordPress 4 Plugin URI: https://oiplug.com/plugin/oi-yandex-maps-for-wordpress/ 5 Description: The plugin allows you to use Yandex.Maps on your site pages and put the placemarks on the map. Without an API key. <strong>Don't forget to reactivate the plugin!</strong> 6 Author: Alexei Isaenko 7 Version: 3.1.8 8 Author URI: https://oiplug.com/members/isaenkoalexei 9 Text Domain: oi-yamaps 10 Domain Path: /language 11 */ 2 /** 3 * Plugin Name: Oi Yandex.Maps for WordPress 4 * Plugin URI: https://oiplug.com/plugin/oi-yandex-maps-for-wordpress/ 5 * Description: The plugin allows you to use Yandex.Maps on your site pages and put the placemarks on the map. Without an API key. <strong>Don't forget to reactivate the plugin!</strong> 6 * Author: Alexei Isaenko 7 * Version: 3.1.9 8 * Author URI: https://oiplug.com/members/isaenkoalexei 9 * Text Domain: oi-yamaps 10 * Domain Path: /language 11 * GitHub Plugin URI: https://github.com/sh14/oi-yamaps 12 */ 12 13 13 14 -
oi-yamaps/trunk/readme.txt
r1914834 r1921678 59 59 == Changelog == 60 60 61 3.1.8 (25.07.2018) 61 = 3.1.9 (08.08.2018) = 62 * fix: plugin header correction; 63 = 3.1.8 (25.07.2018) = 62 64 * fix: custom placemark special attribut added; 63 65 = 3.1.7 (22.06.2018) =
Note: See TracChangeset
for help on using the changeset viewer.