| @@ -72,77 +72,68 @@ | ||
| 72 | 72 | public function content( $attr, $noAjax ) { |
| 73 | 73 | $wraper_before = $wraper_after = $content = $popup_content = ''; |
| 74 | 74 | $block_name = 'advanced-search'; |
| 75 | 75 | |
| 76 | - $is_visible = true; | |
| 77 | - if ( isset( $attr['blockPubDate'] ) && $attr['blockPubDate'] != 'empty' ) { | |
| 78 | - $is_visible = ultimate_post()->is_pro_feature_visible( $attr['blockPubDate'] ); | |
| 79 | - } | |
| 76 | + $attr = wp_parse_args( $attr, $this->get_attributes() ); | |
| 80 | 77 | |
| 81 | - $is_active = ultimate_post()->is_lc_active(); | |
| 78 | + $attr['blockId'] = sanitize_html_class( $attr['blockId'] ); | |
| 79 | + $attr['className'] = isset( $attr['className'] ) && $attr['className'] ? preg_replace( '/[^A-Za-z0-9_ -]/', '', $attr['className'] ) : ''; | |
| 80 | + $attr['align'] = isset( $attr['align'] ) && $attr['align'] ? preg_replace( '/[^A-Za-z0-9_ -]/', '', $attr['align'] ) : ''; | |
| 81 | + $attr['popupAnimation'] = sanitize_html_class( $attr['popupAnimation'] ); | |
| 82 | + $attr['btnNewTab'] = $attr['btnNewTab'] == true; | |
| 83 | + $attr['searchAjaxEnable'] = $attr['searchAjaxEnable'] == true; | |
| 84 | + $attr['enableSearchPage'] = $attr['enableSearchPage'] == true; | |
| 85 | + $attr['resImageEnable'] = $attr['resImageEnable'] == true; | |
| 86 | + $attr['resAuthEnable'] = $attr['resAuthEnable'] == true; | |
| 87 | + $attr['resDateEnable'] = $attr['resDateEnable'] == true; | |
| 88 | + $attr['resExcerptEnable'] = $attr['resExcerptEnable'] == true; | |
| 89 | + $attr['moreResultsbtn'] = $attr['moreResultsbtn'] == true; | |
| 90 | + $attr['resCatEnable'] = $attr['resCatEnable'] == true; | |
| 91 | + $attr['resExcerptLimit'] = sanitize_html_class( $attr['resExcerptLimit'] ); | |
| 92 | + $attr['moreResultPosts'] = sanitize_html_class( $attr['moreResultPosts'] ); | |
| 93 | + $attr['searchPopupPosition'] = sanitize_html_class( $attr['searchPopupPosition'] ); | |
| 94 | + $attr['searchFormStyle'] = sanitize_html_class( $attr['searchFormStyle'] ); | |
| 95 | + $attr['searchPopupIconStyle'] = sanitize_html_class( $attr['searchPopupIconStyle'] ); | |
| 82 | 96 | |
| 83 | - if ( $is_active || $is_visible ) { | |
| 84 | - $attr = wp_parse_args( $attr, $this->get_attributes() ); | |
| 97 | + $allowed_html_tags = ultimate_post()->ultp_allowed_html_tags(); | |
| 98 | + $attr['windowpopupText'] = wp_kses( $attr['windowpopupText'], $allowed_html_tags ); | |
| 99 | + $attr['searchnoresult'] = wp_kses( $attr['searchnoresult'], $allowed_html_tags ); | |
| 100 | + $attr['moreResultsText'] = wp_kses( $attr['moreResultsText'], $allowed_html_tags ); | |
| 101 | + $attr['searchButtonText'] = wp_kses( $attr['searchButtonText'], $allowed_html_tags ); | |
| 102 | + $attr['searchInputPlaceholder'] = wp_kses( $attr['searchInputPlaceholder'], $allowed_html_tags ); | |
| 85 | 103 | |
| 86 | - $attr['blockId'] = sanitize_html_class( $attr['blockId'] ); | |
| 87 | - $attr['className'] = isset( $attr['className'] ) && $attr['className'] ? preg_replace( '/[^A-Za-z0-9_ -]/', '', $attr['className'] ) : ''; | |
| 88 | - $attr['align'] = isset( $attr['align'] ) && $attr['align'] ? preg_replace( '/[^A-Za-z0-9_ -]/', '', $attr['align'] ) : ''; | |
| 89 | - $attr['popupAnimation'] = sanitize_html_class( $attr['popupAnimation'] ); | |
| 90 | - $attr['btnNewTab'] = $attr['btnNewTab'] == true; | |
| 91 | - $attr['searchAjaxEnable'] = $attr['searchAjaxEnable'] == true; | |
| 92 | - $attr['enableSearchPage'] = $attr['enableSearchPage'] == true; | |
| 93 | - $attr['resImageEnable'] = $attr['resImageEnable'] == true; | |
| 94 | - $attr['resAuthEnable'] = $attr['resAuthEnable'] == true; | |
| 95 | - $attr['resDateEnable'] = $attr['resDateEnable'] == true; | |
| 96 | - $attr['resExcerptEnable'] = $attr['resExcerptEnable'] == true; | |
| 97 | - $attr['moreResultsbtn'] = $attr['moreResultsbtn'] == true; | |
| 98 | - $attr['resCatEnable'] = $attr['resCatEnable'] == true; | |
| 99 | - $attr['resExcerptLimit'] = sanitize_html_class( $attr['resExcerptLimit'] ); | |
| 100 | - $attr['moreResultPosts'] = sanitize_html_class( $attr['moreResultPosts'] ); | |
| 101 | - $attr['searchPopupPosition'] = sanitize_html_class( $attr['searchPopupPosition'] ); | |
| 102 | - $attr['searchFormStyle'] = sanitize_html_class( $attr['searchFormStyle'] ); | |
| 103 | - $attr['searchPopupIconStyle'] = sanitize_html_class( $attr['searchPopupIconStyle'] ); | |
| 104 | + $data_var = 'data-searchPostType="' . esc_attr( json_decode( wp_json_encode( $attr['searchPostType'] ) ) ) . '"'; | |
| 105 | + $wraper_before .= '<div ' . ( $attr['advanceId'] ? 'id="' . sanitize_html_class( $attr['advanceId'] ) . '" ' : '' ) . ' class="wp-block-ultimate-post-' . $block_name . ' ultp-block-' . sanitize_html_class( $attr['blockId'] ) . '' . ( $attr['align'] ? ' align' . $attr['align'] : '' ) . '' . ( $attr['className'] ? ' ' . $attr['className'] : '' ) . '">'; | |
| 106 | + $wraper_before .= '<div class="ultp-block-wrapper">'; | |
| 107 | + $content .= '<div class="ultp-search-container ultp-search-frontend' . ( $attr['searchPopup'] ? ' ultp-search-animation-' . $attr['popupAnimation'] : '' ) . '" data-ajax="' . esc_attr( $attr['searchAjaxEnable'] ) . '" data-gosearch="' . esc_attr( $attr['enableSearchPage'] ) . '" data-enablenewtab="' . esc_attr( $attr['btnNewTab'] ) . '" data-blockId="' . esc_attr( $attr['blockId'] ) . '" | |
| 108 | + data-image="' . esc_attr( $attr['resImageEnable'] ) . '" data-author="' . esc_attr( $attr['resAuthEnable'] ) . '" data-date="' . esc_attr( $attr['resDateEnable'] ) . '" data-excerpt="' . esc_attr( $attr['resExcerptEnable'] ) . '" data-excerptLimit="' . esc_attr( $attr['resExcerptLimit'] ) . '" data-allresult="' . esc_attr( $attr['moreResultsbtn'] ) . '" data-catEnable="' . esc_attr( $attr['resCatEnable'] ) . '" data-postno="' . esc_attr( $attr['moreResultPosts'] ) . '" ' . ( $attr['searchPopup'] ? 'data-popuptype="' . esc_attr( $attr['popupAnimation'] ) . '" ' : '' ) . ' ' . ( $attr['searchAjaxEnable'] ? 'data-noresultext="' . esc_attr( $attr['searchnoresult'] ) . '" ' : '' ) . ' ' . ( $attr['moreResultsbtn'] ? 'data-viewmoretext="' . esc_attr( $attr['moreResultsText'] ) . '" ' : '' ) . ' data-popupposition="' . esc_attr( $attr['searchPopupPosition'] ) . '" ' . $data_var . '>'; | |
| 109 | + if ( $attr['searchPopup'] ) { | |
| 110 | + $content .= $this->renderSearchButton( $attr['searchPopupIconStyle'], $attr['searchBtnText'], $attr['searchBtnIcon'], $attr['searchButtonText'] ); | |
| 111 | + } | |
| 112 | + if ( $attr['searchPopup'] == false ) { | |
| 113 | + $content .= $this->renderSearchForm( $attr['searchFormStyle'], $attr['searchBtnText'], $attr['searchBtnIcon'], $attr ); | |
| 114 | + } | |
| 115 | + if ( $attr['searchPopup'] ) { | |
| 116 | + $popup_content .= '<div class="ultp-search-canvas">'; | |
| 104 | 117 | |
| 105 | - $allowed_html_tags = ultimate_post()->ultp_allowed_html_tags(); | |
| 106 | - $attr['windowpopupText'] = wp_kses( $attr['windowpopupText'], $allowed_html_tags ); | |
| 107 | - $attr['searchnoresult'] = wp_kses( $attr['searchnoresult'], $allowed_html_tags ); | |
| 108 | - $attr['moreResultsText'] = wp_kses( $attr['moreResultsText'], $allowed_html_tags ); | |
| 109 | - $attr['searchButtonText'] = wp_kses( $attr['searchButtonText'], $allowed_html_tags ); | |
| 110 | - $attr['searchInputPlaceholder'] = wp_kses( $attr['searchInputPlaceholder'], $allowed_html_tags ); | |
| 111 | - | |
| 112 | - $data_var = 'data-searchPostType=' . json_decode( wp_json_encode( $attr['searchPostType'] ) ); | |
| 113 | - $wraper_before .= '<div ' . ( $attr['advanceId'] ? 'id="' . sanitize_html_class( $attr['advanceId'] ) . '" ' : '' ) . ' class="wp-block-ultimate-post-' . $block_name . ' ultp-block-' . sanitize_html_class( $attr['blockId'] ) . '' . ( $attr['align'] ? ' align' . $attr['align'] : '' ) . '' . ( $attr['className'] ? ' ' . $attr['className'] : '' ) . '">'; | |
| 114 | - $wraper_before .= '<div class="ultp-block-wrapper">'; | |
| 115 | - $content .= '<div class="ultp-search-container ultp-search-frontend' . ( $attr['searchPopup'] ? ' ultp-search-animation-' . $attr['popupAnimation'] : '' ) . '" data-ajax="' . $attr['searchAjaxEnable'] . '" data-gosearch="' . $attr['enableSearchPage'] . '" data-enablenewtab="' . $attr['btnNewTab'] . '" data-blockId="' . $attr['blockId'] . '" | |
| 116 | - data-image="' . $attr['resImageEnable'] . '" data-author=' . $attr['resAuthEnable'] . ' data-date="' . $attr['resDateEnable'] . '" data-excerpt="' . $attr['resExcerptEnable'] . '" data-excerptLimit="' . $attr['resExcerptLimit'] . '" data-allresult="' . $attr['moreResultsbtn'] . '" data-catEnable="' . $attr['resCatEnable'] . '" data-postno="' . $attr['moreResultPosts'] . '" ' . ( $attr['searchPopup'] ? 'data-popuptype="' . $attr['popupAnimation'] . '" ' : '' ) . ' ' . ( $attr['searchAjaxEnable'] ? 'data-noresultext="' . $attr['searchnoresult'] . '" ' : '' ) . ' ' . ( $attr['moreResultsbtn'] ? 'data-viewmoretext="' . $attr['moreResultsText'] . '" ' : '' ) . ' data-popupposition="' . $attr['searchPopupPosition'] . '" ' . $data_var . '>'; | |
| 117 | - if ( $attr['searchPopup'] ) { | |
| 118 | - $content .= $this->renderSearchButton( $attr['searchPopupIconStyle'], $attr['searchBtnText'], $attr['searchBtnIcon'], $attr['searchButtonText'] ); | |
| 118 | + $popup_content .= '<div class="ultp-canvas-header">'; | |
| 119 | + if ( $attr['windowpopupHeading'] ) { | |
| 120 | + $popup_content .= '<div class="ultp-search-popup-heading">' . $attr['windowpopupText'] . '</div>'; | |
| 119 | 121 | } |
| 120 | - if ( $attr['searchPopup'] == false ) { | |
| 121 | - $content .= $this->renderSearchForm( $attr['searchFormStyle'], $attr['searchBtnText'], $attr['searchBtnIcon'], $attr ); | |
| 122 | + $popup_content .= $this->renderSearchForm( $attr['searchFormStyle'], $attr['searchBtnText'], $attr['searchBtnIcon'], $attr ); | |
| 123 | + $popup_content .= '</div>'; | |
| 124 | + $popup_content .= '<div class="ultp-popupclose-icon">' . ultimate_post()->get_svg_icon( 'close_line' ) . '</div>'; | |
| 125 | + $popup_content .= '</div>'; | |
| 126 | + if ( $attr['popupAnimation'] == 'popup' ) { | |
| 127 | + $content .= $popup_content; | |
| 128 | + } else { | |
| 129 | + $content .= $popup_content; | |
| 122 | 130 | } |
| 123 | - if ( $attr['searchPopup'] ) { | |
| 124 | - $popup_content .= '<div class="ultp-search-canvas">'; | |
| 125 | - | |
| 126 | - $popup_content .= '<div class="ultp-canvas-header">'; | |
| 127 | - if ( $attr['windowpopupHeading'] ) { | |
| 128 | - $popup_content .= '<div class="ultp-search-popup-heading">' . $attr['windowpopupText'] . '</div>'; | |
| 129 | - } | |
| 130 | - $popup_content .= $this->renderSearchForm( $attr['searchFormStyle'], $attr['searchBtnText'], $attr['searchBtnIcon'], $attr ); | |
| 131 | - $popup_content .= '</div>'; | |
| 132 | - $popup_content .= '<div class="ultp-popupclose-icon">' . ultimate_post()->get_svg_icon( 'close_line' ) . '</div>'; | |
| 133 | - $popup_content .= '</div>'; | |
| 134 | - if ( $attr['popupAnimation'] == 'popup' ) { | |
| 135 | - $content .= $popup_content; | |
| 136 | - } else { | |
| 137 | - $content .= $popup_content; | |
| 138 | - } | |
| 139 | - } | |
| 140 | - $content .= '</div>'; | |
| 141 | - $wraper_after .= '</div>'; | |
| 142 | - $wraper_after .= '</div>'; | |
| 143 | - return $wraper_before . $content . $wraper_after; | |
| 144 | 131 | } |
| 132 | + $content .= '</div>'; | |
| 133 | + $wraper_after .= '</div>'; | |
| 134 | + $wraper_after .= '</div>'; | |
| 135 | + return $wraper_before . $content . $wraper_after; | |
| 145 | 136 | } |
| 146 | 137 | |
| 147 | 138 | public function renderSearchButton( $style, $textEnable = true, $iconEnable = true, $searchButtonText = '' ) { |
| 148 | 139 | $textShow = $textEnable && $style != 'popup-icon1'; |