', esc_attr( $app_id ) ); } } /** * @param Widget_Base $widget */ public static function add_app_id_control( $widget ) { if ( ! self::get_app_id() ) { $content = sprintf( /* translators: 1: Setting Page Link opening tag, 2: Link closing tag. */ esc_html__( 'Set your Facebook App ID in the %1$sIntegrations Settings%2$s', 'elementor-pro' ), sprintf( '', Settings::get_settings_tab_url( 'integrations' ) ), '' ); $alert_type = 'warning'; } else { $content = sprintf( /* translators: 1: App ID, 2: Setting Page Link opening tag, 3: Link closing tag. */ esc_html__( 'You are connected to Facebook App %1$s, %2$sChange App%3$s', 'elementor-pro' ), self::get_app_id(), sprintf( '', Settings::get_settings_tab_url( 'integrations' ) ), '' ); $alert_type = 'info'; } $widget->add_control( 'app_id', [ 'type' => Controls_Manager::ALERT, 'alert_type' => $alert_type, 'content' => $content, ] ); $widget->add_control( 'app_eu_message', [ 'type' => Controls_Manager::ALERT, 'alert_type' => 'info', 'content' => sprintf( /* translators: 1: Link opening tag, 2: Link closing tag. */ esc_html__( 'For visitors from the EU, Facebook widgets will only work for site visitors if they have logged into Facebook and consented to cookies. %1$sLearn more%2$s', 'elementor-pro' ), sprintf( '', 'https://developers.facebook.com/docs/plugins/' ), '' ), ] ); } public function localize_settings( $settings ) { $settings['facebook_sdk'] = [ 'lang' => self::get_lang(), 'app_id' => self::get_app_id(), ]; return $settings; } public function __construct() { add_action( 'wp_head', [ __CLASS__, 'enqueue_meta_app_id' ] ); add_filter( 'elementor_pro/frontend/localize_settings', [ $this, 'localize_settings' ] ); // The nonce already validated on the options page, if ( ! empty( $_POST['option_page'] ) && 'elementor' === $_POST['option_page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing $this->validate_sdk(); } if ( is_admin() ) { add_action( 'elementor/admin/after_create_settings/' . Settings::PAGE_ID, [ $this, 'register_admin_fields' ] ); } } public static function get_permalink( $settings = [] ) { $post_id = get_the_ID(); if ( isset( $settings['url_format'] ) && Module::URL_FORMAT_PRETTY === $settings['url_format'] ) { return get_permalink( $post_id ); } // Use plain url to avoid losing comments after change the permalink. return add_query_arg( 'p', $post_id, home_url() ); } public function register_admin_fields( Settings $settings ) { $settings->add_section( Settings::TAB_INTEGRATIONS, 'facebook_sdk', [ 'callback' => function() { echo '