Admin
2 weeks ago
Builder
2 weeks ago
Helpers
2 weeks ago
Integrations
2 weeks ago
UsageTracking
2 weeks ago
CFF_Autolink.php
2 weeks ago
CFF_Blocks.php
2 weeks ago
CFF_Cache.php
2 weeks ago
CFF_Education.php
2 weeks ago
CFF_Elementor_Base.php
2 weeks ago
CFF_Elementor_Widget.php
2 weeks ago
CFF_Error_Reporter.php
2 weeks ago
CFF_FB_Settings.php
2 weeks ago
CFF_Feed_Elementor_Control.php
2 weeks ago
CFF_Feed_Locator.php
2 weeks ago
CFF_Feed_Pro.php
2 weeks ago
CFF_GDPR_Integrations.php
2 weeks ago
CFF_Group_Posts.php
2 weeks ago
CFF_HTTP_Request.php
2 weeks ago
CFF_Oembed.php
2 weeks ago
CFF_Parse.php
2 weeks ago
CFF_Resizer.php
2 weeks ago
CFF_Response.php
2 weeks ago
CFF_Shortcode.php
2 weeks ago
CFF_Shortcode_Display.php
2 weeks ago
CFF_SiteHealth.php
2 weeks ago
CFF_Utils.php
2 weeks ago
CFF_View.php
2 weeks ago
Custom_Facebook_Feed.php
2 weeks ago
Email_Notification.php
2 weeks ago
Platform_Data.php
2 weeks ago
SB_Facebook_Data_Encryption.php
2 weeks ago
SB_Facebook_Data_Manager.php
2 weeks ago
index.php
2 weeks ago
CFF_Elementor_Base.php
119 lines
| 1 | <?php |
| 2 | |
| 3 | namespace CustomFacebookFeed; |
| 4 | |
| 5 | use FacebookFeed\Vendor\Smashballoon\Framework\Packages\Blocks\RecommendedElementorWidgets; |
| 6 | use FacebookFeed\Vendor\Smashballoon\Framework\Packages\Blocks\SB_Feed_Blocks_Registry; |
| 7 | use FacebookFeed\Vendor\Smashballoon\Framework\Packages\Blocks\SB_Block_Utils; |
| 8 | use FacebookFeed\Vendor\Smashballoon\Framework\Packages\Blocks\SB_Elementor_Editor_Assets; |
| 9 | use CustomFacebookFeed\Builder\CFF_Db; |
| 10 | |
| 11 | if (!defined('ABSPATH')) { |
| 12 | exit; // Exit if accessed directly |
| 13 | } |
| 14 | |
| 15 | |
| 16 | class CFF_Elementor_Base |
| 17 | { |
| 18 | private static $instance = null; |
| 19 | |
| 20 | public static function register() { |
| 21 | if ( null === self::$instance ) { |
| 22 | self::$instance = new self(); |
| 23 | self::$instance->init(); |
| 24 | } |
| 25 | return self::$instance; |
| 26 | } |
| 27 | |
| 28 | public static function instance() { |
| 29 | return self::register(); |
| 30 | } |
| 31 | |
| 32 | private function init() { |
| 33 | if ( doing_action( 'init' ) || did_action( 'init' ) ) { |
| 34 | $this->init_elementor_integration(); |
| 35 | } else { |
| 36 | add_action( 'init', array( $this, 'init_elementor_integration' ), 4 ); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | public function init_elementor_integration() { |
| 41 | if ( ! did_action( 'elementor/loaded' ) ) { |
| 42 | return; |
| 43 | } |
| 44 | |
| 45 | $recommended = new RecommendedElementorWidgets( 'facebook' ); |
| 46 | $recommended->setup(); |
| 47 | |
| 48 | $registry = SB_Feed_Blocks_Registry::instance(); |
| 49 | $registry->register_elementor_widget( |
| 50 | array( |
| 51 | 'blockId' => 'facebook', |
| 52 | 'widgetName' => 'sb-facebook-feed', |
| 53 | 'globalVar' => 'cffElementorData', |
| 54 | 'feedInitFn' => 'cff_init', |
| 55 | ) |
| 56 | ); |
| 57 | |
| 58 | add_action( 'elementor/widgets/register', array( $this, 'register_widgets' ) ); |
| 59 | add_action( 'elementor/controls/register', array( $this, 'register_controls' ) ); |
| 60 | add_action( 'elementor/frontend/after_register_scripts', array( $this, 'register_frontend_scripts' ) ); |
| 61 | add_action( 'elementor/elements/categories_registered', array( $this, 'add_smashballoon_categories' ) ); |
| 62 | add_action( 'elementor/editor/after_enqueue_scripts', array( $this, 'enqueue_editor_scripts' ) ); |
| 63 | } |
| 64 | |
| 65 | public function register_widgets( $widgets_manager ) { |
| 66 | // Register modern widget |
| 67 | require_once trailingslashit( CFF_PLUGIN_DIR ) . 'inc/Integrations/Elementor/CFF_Modern_Elementor_Widget.php'; |
| 68 | $widgets_manager->register( new \CustomFacebookFeed\Integrations\Elementor\CFF_Modern_Elementor_Widget() ); |
| 69 | |
| 70 | // Register legacy widget for backward compatibility (existing pages use 'cff-widget' type) |
| 71 | require_once trailingslashit( CFF_PLUGIN_DIR ) . 'inc/CFF_Elementor_Widget.php'; |
| 72 | $widgets_manager->register( new \CustomFacebookFeed\CFF_Elementor_Widget() ); |
| 73 | } |
| 74 | |
| 75 | public function register_controls( $controls_manager ) { |
| 76 | require_once trailingslashit( CFF_PLUGIN_DIR ) . 'inc/CFF_Feed_Elementor_Control.php'; |
| 77 | $controls_manager->register( new \CustomFacebookFeed\CFF_Feed_Elementor_Control() ); |
| 78 | } |
| 79 | |
| 80 | public function register_frontend_scripts() { |
| 81 | \cff_main()->enqueue_styles_assets(); |
| 82 | \cff_main()->enqueue_scripts_assets(); |
| 83 | |
| 84 | $feeds = CFF_Db::elementor_feeds_list(); |
| 85 | |
| 86 | $data = array( |
| 87 | 'feeds' => ! empty( $feeds ) ? $feeds : array(), |
| 88 | 'feed_url' => admin_url( 'admin.php?page=cff-feed-builder' ), |
| 89 | 'is_pro_active' => CFF_Utils::cff_is_pro_version(), |
| 90 | ); |
| 91 | |
| 92 | wp_localize_script( 'cffscripts', 'cffElementorData', $data ); |
| 93 | |
| 94 | wp_register_script( |
| 95 | 'elementor-preview', |
| 96 | CFF_PLUGIN_URL . 'assets/js/elementor-preview.js', |
| 97 | array( 'jquery' ), |
| 98 | CFFVER, |
| 99 | true |
| 100 | ); |
| 101 | |
| 102 | SB_Feed_Blocks_Registry::instance()->enqueue_elementor_assets(); |
| 103 | } |
| 104 | |
| 105 | public function add_smashballoon_categories( $elements_manager ) { |
| 106 | $elements_manager->add_category( |
| 107 | SB_Block_Utils::CATEGORY_SLUG, |
| 108 | array( |
| 109 | 'title' => esc_html__( 'Smash Balloon', 'custom-facebook-feed' ), |
| 110 | 'icon' => 'fa fa-plug', |
| 111 | ) |
| 112 | ); |
| 113 | } |
| 114 | |
| 115 | public function enqueue_editor_scripts() { |
| 116 | SB_Elementor_Editor_Assets::enqueue_shared_elementor_styles( CFFVER ); |
| 117 | } |
| 118 | } |
| 119 |