/** * Iterate through possible view types for subscribe button * Change subscribe to follow if found * * @since 1.1.9 */ public static function update_views() { if (!class_exists('Facebook_Follow_Button_Settings')) { require_once dirname(__FILE__) . '/settings-follow-button.php'; } // archives + post types $all_possible_display_types = Facebook_Social_Plugin_Settings::get_show_on_choices('all'); // archives + post types supporting authorship $follow_display_types = Facebook_Follow_Button_Settings::get_show_on_choices(); // iterate through all display types, looking for our feature in each foreach ($all_possible_display_types as $display_type) { $option_name = "facebook_{$display_type}_features"; $display_preferences = get_option($option_name); if (!is_array($display_preferences)) { continue; } if (isset($display_preferences['subscribe'])) { unset($display_preferences['subscribe']); // remove any post types not supporting authorship if (in_array($display_type, $follow_display_types, true)) { $display_preferences['follow'] = true; } // save new values update_option($option_name, $display_preferences); } unset($option_name); unset($display_preferences); } }
/** * Which features are enabled for the site on each major view type? * * @since 1.1.6 * * @return void */ public static function enabled_features_by_view_type() { if (!class_exists('Facebook_Social_Plugin_Settings')) { require_once dirname(__FILE__) . '/settings-social-plugin.php'; } $views = Facebook_Social_Plugin_Settings::get_show_on_choices('all'); if (!is_array($views) || empty($views)) { return; } echo '<section id="debug-social-plugins"><header><h3>' . esc_html(__('Social Plugins', 'facebook')) . '</h3></header>'; echo '<table><caption>' . esc_html(_x('Features enabled by view type', 'software features available based on different classifications website view', 'facebook')) . '</caption>'; $features = array('like' => array('name' => __('Like Button', 'facebook'), 'url' => 'https://developers.facebook.com/docs/reference/plugins/like/'), 'send' => array('name' => __('Send Button', 'facebook'), 'url' => 'https://developers.facebook.com/docs/reference/plugins/send/'), 'follow' => array('name' => __('Follow Button', 'facebook'), 'url' => 'https://developers.facebook.com/docs/reference/plugins/follow/'), 'recommendations_bar' => array('name' => __('Recommendations Bar', 'facebook'), 'url' => 'https://developers.facebook.com/docs/reference/plugins/recommendationsbar/'), 'comments' => array('name' => __('Comments Box', 'facebook'), 'url' => 'https://developers.facebook.com/docs/reference/plugins/comments/')); echo '<thead><tr><th>' . esc_html(__('View', 'facebook')) . '</th>'; foreach ($features as $slug => $properties) { echo '<th>'; if (isset($properties['url'])) { echo '<a href="' . esc_url($properties['url'], array('http', 'https')) . '">' . esc_html($properties['name']) . '</a>'; } else { echo esc_html($properties['name']); } echo '</th>'; } echo '</tr></thead><tbody>'; foreach ($views as $view) { echo '<tr><th>' . $view . '</th>'; $view_features = get_option('facebook_' . $view . '_features'); if (!is_array($view_features)) { $view_features = array(); } foreach ($features as $feature => $properties) { echo '<td>'; if (isset($view_features[$feature])) { echo self::EXISTS; } else { echo ' '; } echo '</td>'; } echo '</tr>'; } echo '</tbody></table>'; echo '</section>'; }
/** * Identify active features for debugging purposes or sent via a Facebook beacon * * @since 1.1 * * @global Facebook_Loader $facebook_loader Access Facebook application information * @param string $app_id Facebook application identifier * @return array { * debug information * * @type string parameter to include in debugger (typically as a URI query parameter) * @type string|array information about the current site installation * } */ public static function debug_output($app_id = '') { global $facebook_loader; $debug = array(); // Facebook application identifier if (!$app_id && isset($facebook_loader) && isset($facebook_loader->credentials['app_id'])) { $app_id = $facebook_loader->credentials['app_id']; } if ($app_id) { $debug['appid'] = $app_id; } // plugin version if (isset($facebook_loader)) { $debug['version'] = Facebook_Loader::VERSION; } // site domain $hostname = parse_url(site_url(), PHP_URL_HOST); if ($hostname) { $debug['domain'] = $hostname; } unset($hostname); // where are we running? if (!class_exists('Facebook_Social_Plugin_Settings')) { require_once dirname(__FILE__) . '/settings-social-plugin.php'; } $enabled_features = array(); $views = Facebook_Social_Plugin_Settings::get_show_on_choices('all'); foreach ($views as $view) { $features = get_option('facebook_' . $view . '_features'); if (is_array($features) && !empty($features)) { $enabled_features[$view] = array_keys($features); } else { $enabled_features[$view] = false; } // show a potential target where nothing appears unset($features); } unset($views); if (!empty($enabled_features)) { $debug['features'] = $enabled_features; } unset($enabled_features); // active widgets $widgets = self::get_active_widgets(); if (!empty($widgets)) { $debug['widgets'] = $widgets; } return $debug; }
/** * Identify active features for debugging purposes or sent via a Facebook beacon * * @since 1.1 * @param string $app_id application identifier * @return array debug information */ public static function debug_output($app_id = '') { global $facebook_loader; if (!$app_id && isset($facebook_loader) && isset($facebook_loader->credentials['app_id'])) { $app_id = $facebook_loader->credentials['app_id']; } $debug = array(); if ($app_id) { $debug['appid'] = $app_id; } if (isset($facebook_loader)) { $debug['version'] = Facebook_Loader::VERSION; } $hostname = parse_url(site_url(), PHP_URL_HOST); if ($hostname) { $debug['domain'] = $hostname; } unset($hostname); // where are we running? if (!class_exists('Facebook_Social_Plugin_Settings')) { require_once dirname(__FILE__) . '/settings-social-plugin.php'; } $enabled_features = array(); $all_targets = Facebook_Social_Plugin_Settings::get_show_on_choices('all'); $option_name = 'facebook_%s_features'; foreach ($all_targets as $target) { $features = get_option(sprintf($option_name, $target)); if (is_array($features) && !empty($features)) { $enabled_features[$target] = $features; } else { $enabled_features[$target] = false; } // show a potential target where nothing appears unset($features); } unset($option_name); unset($all_targets); if (!empty($enabled_features)) { $debug['features'] = $enabled_features; } unset($enabled_features); $sidebar_widgets = wp_get_sidebars_widgets(); unset($sidebar_widgets['wp_inactive_widgets']); // no need to track inactives $sidebar_widgets = array_unique(array_merge(array_values($sidebar_widgets))); // track widgets, not sidebar names if (is_array($sidebar_widgets) && isset($sidebar_widgets[0])) { $sidebar_widgets = $sidebar_widgets[0]; $widgets = array(); // iterate through each sidebar configuration // note any facebook widgets we find along the way foreach ($sidebar_widgets as $widget_id) { if (strlen($widget_id) > 9 && substr_compare($widget_id, 'facebook-', 0, 9) === 0) { $feature = substr($widget_id, 9, strrpos($widget_id, '-') - 9); if (!isset($widgets[$feature])) { $widgets[$feature] = true; } unset($feature); } } if (!empty($widgets)) { $debug['widgets'] = array_keys($widgets); } unset($widgets); } return $debug; }