Analytics
2 weeks ago
Divi
2 weeks ago
Elementor
2 weeks ago
CFF_API_Connect.php
2 weeks ago
CFF_Graph_Data.php
2 weeks ago
CFF_Graph_Url.php
2 weeks ago
CFF_Integration.php
2 weeks ago
index.php
2 weeks ago
CFF_Integration.php
130 lines
| 1 | <?php |
| 2 | |
| 3 | namespace CustomFacebookFeed\Integrations; |
| 4 | |
| 5 | use CustomFacebookFeed\CFF_Utils; |
| 6 | use CustomFacebookFeed\Builder\CFF_Db; |
| 7 | use CustomFacebookFeed\Builder\CFF_Feed_Builder; |
| 8 | |
| 9 | if (!defined('ABSPATH')) { |
| 10 | exit; // Exit if accessed directly |
| 11 | } |
| 12 | |
| 13 | /** |
| 14 | * CFF_Integration |
| 15 | * Common funcions for Elementor/Divi/Gutenberg |
| 16 | * |
| 17 | * @since 4.3 |
| 18 | * |
| 19 | * @return array |
| 20 | */ |
| 21 | |
| 22 | class CFF_Integration |
| 23 | { |
| 24 | /** |
| 25 | * Get Widget/Module/Block Info |
| 26 | * |
| 27 | * @since 4.3 |
| 28 | * |
| 29 | * @return array |
| 30 | */ |
| 31 | public static function get_widget_info() |
| 32 | { |
| 33 | return [ |
| 34 | 'plugin' => 'facebook', |
| 35 | 'cta_header' => __('Get started with your first feed from your<br/>Facebook Page or Group', 'custom-facebook-feed'), |
| 36 | 'cta_header2' => __('Select a Facebook feed to embed', 'custom-facebook-feed'), |
| 37 | 'cta_description_free' => sprintf( |
| 38 | __('You can display feeds of Facebook photos, videos, albums, events and more using the %sPro version%s ', 'custom-facebook-feed'), |
| 39 | '<a class="sb-elementor-cta-link" href="https://smashballoon.com/custom-facebook-feed/?utm_campaign=facebook-free&utm_source=elementor&utm_medium=widget&utm_content=proversion">', |
| 40 | '</a>' |
| 41 | ), |
| 42 | 'cta_description_pro' => sprintf( |
| 43 | __('You can also add Instagram, Twitter, and YouTube posts into your feed using our %sSocial Wall plugin%s ', 'custom-facebook-feed'), |
| 44 | '<a class="sb-elementor-cta-link" href="https://smashballoon.com/social-wall/?utm_campaign=facebook-free&utm_source=elementor&utm_medium=widget&utm_content=socialwall">', |
| 45 | '</a>' |
| 46 | ), |
| 47 | 'plugins' => CFF_Feed_Builder::get_smashballoon_plugins_info() |
| 48 | |
| 49 | ]; |
| 50 | } |
| 51 | |
| 52 | |
| 53 | /** |
| 54 | * Widget CTA |
| 55 | * |
| 56 | * @since 4.3 |
| 57 | * |
| 58 | * @return HTML |
| 59 | */ |
| 60 | public static function get_widget_cta($type = 'dropdown') |
| 61 | { |
| 62 | $widget_cta_html = ''; |
| 63 | $feeds_list = CFF_Db::elementor_feeds_query(); |
| 64 | ob_start(); |
| 65 | self::get_widget_cta_html($feeds_list, $type); |
| 66 | $widget_cta_html .= ob_get_contents(); |
| 67 | ob_get_clean(); |
| 68 | return $widget_cta_html; |
| 69 | } |
| 70 | |
| 71 | public static function get_widget_cta_html($feeds_list, $type) |
| 72 | { |
| 73 | $info = self::get_widget_info(); |
| 74 | $feeds_exist = is_array($feeds_list) && sizeof($feeds_list) > 0; |
| 75 | ?> |
| 76 | <div class="sb-elementor-cta"> |
| 77 | <div class="sb-elementor-cta-img-ctn"> |
| 78 | <div class="sb-elementor-cta-img"> |
| 79 | <span><?php echo $info['plugins'][$info['plugin']]['icon']; ?></span> |
| 80 | <svg class="sb-elementor-cta-logo" width="31" height="39" viewBox="0 0 31 39" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1.62525 18.4447C1.62525 26.7883 6.60827 33.9305 13.3915 35.171L12.9954 36.4252L12.5937 37.6973L13.923 37.5843L18.4105 37.2026L20.0997 37.0589L19.0261 35.7468L18.4015 34.9834C24.7525 33.3286 29.3269 26.4321 29.3269 18.4447C29.3269 9.29016 23.2952 1.53113 15.4774 1.53113C7.65975 1.53113 1.62525 9.2899 1.62525 18.4447Z" fill="#FE544F" stroke="white" stroke-width="1.78661"/><path fill-rule="evenodd" clip-rule="evenodd" d="M18.5669 8.05676L19.1904 14.4905L25.6512 14.6761L20.9776 19.0216L24.6689 24.3606L18.4503 23.1916L16.5651 29.4104L13.7026 23.8415L7.92284 26.4899L10.1462 20.5199L4.50931 17.6767L10.5435 15.7361L8.8784 9.79176L14.5871 13.0464L18.5669 8.05676Z" fill="white"/></svg> |
| 81 | </div> |
| 82 | </div> |
| 83 | <h3 class="sb-elementor-cta-heading"><?php echo $feeds_exist ? $info['cta_header2'] : $info['cta_header'] ?></h3> |
| 84 | |
| 85 | <?php if ($feeds_exist) : ?> |
| 86 | <div class="sb-elementor-cta-selector"> |
| 87 | |
| 88 | <?php if ($type == 'dropdown') : ?> |
| 89 | <select class="sb-elementor-cta-feedselector"> |
| 90 | <?php foreach ($feeds_list as $feed_id => $feed_name) : ?> |
| 91 | <option value="<?php echo $feed_id ?>"><?php echo $feed_name ?></option> |
| 92 | <?php endforeach ?> |
| 93 | </select> |
| 94 | <?php elseif ($type == 'button') : ?> |
| 95 | <a href="<?php echo esc_url(admin_url('admin.php?page=cff-feed-builder')) ?>" rel="noopener noreferrer" class="sb-elementor-cta-btn sb-elementor-cta-link"> |
| 96 | <?php echo esc_html__('Create Facebook Feed', 'custom-facebook-feed'); ?> |
| 97 | </a> |
| 98 | <?php endif; ?> |
| 99 | |
| 100 | <span> |
| 101 | <?php |
| 102 | echo esc_html__('Or create a Feed for', 'custom-facebook-feed'); |
| 103 | unset($info['plugins'][$info['plugin']]); |
| 104 | foreach ($info['plugins'] as $name => $plugin) : |
| 105 | ?> |
| 106 | <a class="sb-elementor-cta-link" href="<?php echo esc_url($plugin['link']) ?>" target="_blank"><?php echo $name ?></a> |
| 107 | <?php endforeach ?> |
| 108 | </span> |
| 109 | </div> |
| 110 | <?php else : ?> |
| 111 | <a href="<?php echo esc_url(admin_url('admin.php?page=cff-feed-builder')) ?>" class="sb-elementor-cta-btn" rel="noopener noreferrer" target="_blank"> |
| 112 | <?php echo esc_html__('Create', 'custom-facebook-feed') . ' ' . $info['plugin'] . ' ' . esc_html__('Feed', 'custom-facebook-feed') ?> |
| 113 | </a> |
| 114 | <?php endif; ?> |
| 115 | |
| 116 | <div class="sb-elementor-cta-desc"> |
| 117 | <strong><?php echo esc_html__('Did you Know?', 'custom-facebook-feed') ?></strong> |
| 118 | <span> |
| 119 | <?php |
| 120 | echo CFF_Utils::cff_is_pro_version() |
| 121 | ? $info['cta_description_pro'] |
| 122 | : $info['cta_description_free']; |
| 123 | ?> |
| 124 | </span> |
| 125 | </div> |
| 126 | </div> |
| 127 | <?php |
| 128 | } |
| 129 | } |
| 130 |