ontent', $filter ); $this->content_removed_filters[] = $filter; } } } /** * Has Elementor In Page * * Determine whether the current page is using Elementor. * * @since 2.0.9 * * @access public * @return bool */ public function has_elementor_in_page() { return $this->_has_elementor_in_page; } public function create_action_hash( $action, array $settings = [] ) { return '#' . rawurlencode( sprintf( 'elementor-action:action=%1$s&settings=%2$s', $action, base64_encode( wp_json_encode( $settings ) ) ) ); } /** * Is the current render mode is static. * * @return bool */ public function is_static_render_mode() { // The render mode manager is exists only in frontend, // so by default if it is not exist the method will return false. if ( ! $this->render_mode_manager ) { return false; } return $this->render_mode_manager->get_current()->is_static(); } /** * Get Init Settings * * Used to define the default/initial settings of the object. Inheriting classes may implement this method to define * their own default/initial settings. * * @since 2.3.0 * * @access protected * @return array */ protected function get_init_settings() { $is_preview_mode = Plugin::$instance->preview->is_preview_mode( Plugin::$instance->preview->get_post_id() ); $active_experimental_features = Plugin::$instance->experiments->get_active_features(); $active_experimental_features = array_fill_keys( array_keys( $active_experimental_features ), true ); $assets_url = ELEMENTOR_ASSETS_URL; /** * Frontend assets URL * * Filters Elementor frontend assets URL. * * @since 2.3.0 * * @param string $assets_url The frontend assets URL. Default is ELEMENTOR_ASSETS_URL. */ $assets_url = apply_filters( 'elementor/frontend/assets_url', $assets_url ); $settings = [ 'environmentMode' => [ 'edit' => $is_preview_mode, 'wpPreview' => is_preview(), 'isScriptDebug' => Utils::is_script_debug(), ], 'i18n' => [ 'shareOnFacebook' => esc_html__( 'Share on Facebook', 'elementor' ), 'shareOnTwitter' => esc_html__( 'Share on Twitter', 'elementor' ), 'pinIt' => esc_html__( 'Pin it', 'elementor' ), 'download' => esc_html__( 'Download', 'elementor' ), 'downloadImage' => esc_html__( 'Download image', 'elementor' ), 'fullscreen' => esc_html__( 'Fullscreen', 'elementor' ), 'zoom' => esc_html__( 'Zoom', 'elementor' ), 'share' => esc_html__( 'Share', 'elementor' ), 'playVideo' => esc_html__( 'Play Video', 'elementor' ), 'previous' => esc_html__( 'Previous', 'elementor' ), 'next' => esc_html__( 'Next', 'elementor' ), 'close' => esc_html__( 'Close', 'elementor' ), 'a11yCarouselWrapperAriaLabel' => __( 'Carousel | Horizontal scrolling: Arrow Left & Right', 'elementor' ), 'a11yCarouselPrevSlideMessage' => __( 'Previous slide', 'elementor' ), 'a11yCarouselNextSlideMessage' => __( 'Next slide', 'elementor' ), 'a11yCarouselFirstSlideMessage' => __( 'This is the first slide', 'elementor' ), 'a11yCarouselLastSlideMessage' => __( 'This is the last slide', 'elementor' ), 'a11yCarouselPaginationBulletMessage' => __( 'Go to slide', 'elementor' ), ], 'is_rtl' => is_rtl(), // 'breakpoints' object is kept for BC. 'breakpoints' => Responsive::get_breakpoints(), // 'responsive' contains the custom breakpoints config introduced in Elementor v3.2.0 'responsive' => [ 'breakpoints' => Plugin::$instance->breakpoints->get_breakpoints_config(), 'hasCustomBreakpoints' => Plugin::$instance->breakpoints->has_custom_breakpoints(), ], 'version' => ELEMENTOR_VERSION, 'is_static' => $this->is_static_render_mode(), 'experimentalFeatures' => $active_experimental_features, 'urls' => [ 'assets' => $assets_url, 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'uploadUrl' => wp_upload_dir()['baseurl'], ], 'nonces' => [ 'floatingButtonsClickTracking' => wp_create_nonce( Module::CLICK_TRACKING_NONCE ), ], 'swiperClass' => Plugin::$instance->experiments->is_feature_active( 'e_swiper_latest' ) ? 'swiper' : 'swiper-container', ]; $settings['settings'] = SettingsManager::get_settings_frontend_config(); $kit = Plugin::$instance->kits_manager->get_active_kit_for_frontend(); $settings['kit'] = $kit->get_frontend_settings(); if ( is_singular() ) { $post = get_post(); $title = Utils::urlencode_html_entities( wp_get_document_title() ); // Try to use the 'large' WP image size because the Pinterest share API // has problems accepting shares with large images sometimes, and the WP 'large' thumbnail is // the largest default WP image size that will probably not be changed in most sites $featured_image_url = get_the_post_thumbnail_url( null, 'large' ); // If the large size was nullified, use the full size which cannot be nullified/deleted if ( ! $featured_image_url ) { $featured_image_url = get_the_post_thumbnail_url( null, 'full' ); } $settings['post'] = [ 'id' => $post->ID, 'title' => $title, 'excerpt' => $post->post_excerpt, 'featuredImage' => $featured_image_url, ]; } else { $settings['post'] = [ 'id' => 0, 'title' => wp_get_document_title(), 'excerpt' => get_the_archive_description(), ]; } $empty_object = (object) []; if ( $is_preview_mode ) { $settings['elements'] = [ 'data' => $empty_object, 'editSettings' => $empty_object, 'keys' => $empty_object, ]; } if ( is_user_logged_in() ) { $user = wp_get_current_user(); if ( ! empty( $user->roles ) ) { $settings['user'] = [ 'roles' => $user->roles, ]; } } return $settings; } /** * Restore content filters. * * Restore removed WordPress filters that conflicted with Elementor. * * @since 1.5.0 * @access public */ public function restore_content_filters() { foreach ( $this->content_removed_filters as $filter ) { add_filter( 'the_content', $filter ); } $this->content_removed_filters = []; } /** * Process More Tag * * Respect the native WP () tag * * @access private * @since 2.0.4 * * @param $content * * @return string */ private function process_more_tag( $content ) { $post = get_post(); $content = str_replace( '<!--more-->', '', $content ); $parts = get_extended( $content ); if ( empty( $parts['extended'] ) ) { return $content; } if ( is_singular() ) { return $parts['main'] . '
' . $parts['extended']; } if ( empty( $parts['more_text'] ) ) { $parts['more_text'] = esc_html__( '(more…)', 'elementor' ); } $more_link_text = sprintf( '%2$s', sprintf( /* translators: %s: Current post name. */ __( 'Continue reading %s', 'elementor' ), the_title_attribute( [ 'echo' => false, ] ) ), $parts['more_text'] ); $more_link = sprintf( ' %s', get_permalink(), $post->ID, $more_link_text ); /** * The content "more" link. * * Filters the "more" link displayed after the content. * * This hook can be used either to change the link syntax or to change the * text inside the link. * * @since 2.0.4 * * @param string $more_link The more link. * @param string $more_link_text The text inside the more link. */ $more_link = apply_filters( 'the_content_more_link', $more_link, $more_link_text ); return force_balance_tags( $parts['main'] ) . $more_link; } }