'share-my-post', 'label' => __('Sharing Buttons', 'addons-for-divi'), 'desc' => __('Inline or floating share buttons.', 'addons-for-divi'), 'active' => self::share_my_post_active(), 'toggleable' => true, 'configure' => 'share-my-post', 'locked' => false, 'note' => '', ), array( 'slug' => 'divi-library-shortcode', 'label' => __('Library Shortcode', 'addons-for-divi'), 'desc' => __('Shortcode for any Library layout.', 'addons-for-divi'), 'active' => self::library_shortcode_active(), 'toggleable' => false, 'configure' => '', 'locked' => false, // Honest about why there is no switch: it is not a preference. 'note' => self::library_shortcode_active() ? __('Always on. Find the shortcode in the Divi Library list.', 'addons-for-divi') : __('Replaced by the same feature in Divi Torque Pro.', 'addons-for-divi'), ), ); foreach (self::PRO_SLUGS as $slug) { $extensions[] = array( 'slug' => $slug, 'label' => '', 'desc' => '', 'active' => false, 'toggleable' => false, 'configure' => '', 'locked' => true, 'note' => '', ); } return $extensions; } /** * Flip an extension on or off. Only ever writes an option that already * exists, and refuses anything not declared toggleable. * * @param string $slug * @param bool $active * @return bool True when the state was applied. */ public static function set_active($slug, $active) { if ('share-my-post' !== $slug) { return false; } $settings = Share_My_Post_Settings::get(); $settings['general']['enabled'] = (bool) $active; Share_My_Post_Settings::update($settings); return true; } private static function share_my_post_active() { $settings = Share_My_Post_Settings::get(); return !empty($settings['general']['enabled']); } /** * Mirrors the load condition in Plugin::init() — the shortcode is only * registered on sites that never had the old Divi Torque plugin, because * Pro ships the same shortcode and two registrations would collide. */ private static function library_shortcode_active() { return !get_option('divitorque_version'); } }