/** * Hooks to appropriate places and adds stuff as needed. * * @access private */ function add_hooks() { // Step1a: Add script and style dependencies //add_action('wp_print_scripts', array($this, 'js_load_scripts')); $footer_hook = wdfb_get_footer_hook(); if (!(defined('WDFB_FB_ASYNC_INIT') && WDFB_FB_ASYNC_INIT)) { $hook = defined('WDFB_LEGACY_SCRIPT_PLACEMENT') && WDFB_LEGACY_SCRIPT_PLACEMENT ? 'wp_head' : $footer_hook; add_action($hook, array($this, 'js_load_scripts')); } add_action('wp_print_styles', array($this, 'css_load_styles')); add_action('wp_head', array($this, 'js_setup_ajaxurl')); add_action($footer_hook, array($this, 'inject_fb_root_div'), 99); add_action($footer_hook, array($this, 'inject_fb_init_js'), 99); /* // Automatic Facebook button if ('manual' != $this->data->get_option('wdfb_button', 'button_position')) { add_filter('the_content', array($this, 'inject_facebook_button'), 10); if (defined('BP_VERSION')) add_filter('bp_get_activity_content_body', array($this, 'inject_facebook_button_bp')); } */ // OpenGraph if ($this->data->get_option('wdfb_opengraph', 'use_opengraph')) { add_action('wp_head', array($this, 'inject_opengraph_info')); } // Connect if ($this->data->get_option('wdfb_connect', 'allow_facebook_registration')) { if (!$this->data->get_option('wdfb_connect', 'skip_fb_avatars')) { add_filter('get_avatar', array($this, 'get_fb_avatar'), 10, 3); } add_action('login_enqueue_scripts', create_function('', 'wp_enqueue_script("jquery");')); add_action('login_head', array($this, 'js_inject_fb_login_script')); add_action('login_head', array($this, 'js_setup_ajaxurl')); add_action('login_form', array($this, 'inject_fb_login')); add_action('login_footer', array($this, 'inject_fb_root_div')); add_action('login_footer', array($this, 'inject_fb_init_js'), 999); // Bind very late, so footer script can execute. // BuddyPress if (defined('BP_VERSION')) { add_action('bp_before_profile_edit_content', 'wdfb_dashboard_profile_widget'); add_action('bp_before_sidebar_login_form', array($this, 'inject_fb_login_for_bp')); add_action('wp_head', array($this, 'js_inject_fb_login_script')); // Have to kill BuddyPress redirection, or our registration doesn't work remove_action('wp', 'bp_core_wpsignup_redirect'); remove_action('init', 'bp_core_wpsignup_redirect'); add_action('bp_include', create_function('', "remove_action('bp_init', 'bp_core_wpsignup_redirect');"), 99); // Untangle for BP 1.5 remove_action('bp_init', 'bp_core_wpsignup_redirect'); // Die already, will you? Pl0x? } // New login/register // First, do optionals if (is_multisite()) { add_action('before_signup_form', array($this, 'inject_optional_facebook_registration_button')); } // Cole's changeset if (WDFB_MEMBERSHIP_INSTALLED) { add_action('signup_hidden_fields', array($this, 'inject_optional_facebook_registration_button')); add_action('bp_before_account_details_fields', array($this, 'inject_optional_facebook_registration_button')); add_action('membership_popover_extend_registration_form', array($this, 'inject_optional_facebook_registration_button')); add_action('signup_extra_fields', array($this, 'inject_fb_login')); add_action('membership_popover_extend_login_form', array($this, 'inject_fb_login')); } else { // BuddyPress add_filter('bp_before_register_page', array($this, 'inject_optional_facebook_registration_button')); // BuddyPress } if (!is_multisite() && isset($_GET['action']) && 'register' == $_GET['action']) { add_action('login_head', create_function('', 'echo "<link rel=\\"stylesheet\\" type=\\"text/css\\" href=\\"' . WDFB_PLUGIN_URL . '/css/wdfb.css\\" />";')); // Better registration button placement for single site // Fix by riyaku // Thank you so much! add_action('register_form', array($this, 'inject_optional_facebook_registration_button')); } // Jack the signup add_action('init', array($this, 'process_facebook_registration'), 20); } // Comments if ($this->data->get_option('wdfb_comments', 'use_fb_comments')) { $hook = $this->data->get_option('wdfb_comments', 'fb_comments_custom_hook'); add_action('wp_head', array($this, 'inject_fb_comments_admin_og')); if (!$hook) { add_filter('comment_form_defaults', array($this, 'inject_fb_comments')); add_filter('bp_before_blog_comment_list', array($this, 'inject_fb_comments')); // BuddyPress :/ } else { add_action($hook, array($this, 'inject_fb_comments')); } } if (!$this->data->get_option('wdfb_connect', 'skip_fb_avatars')) { add_filter('get_avatar', array($this, 'get_commenter_avatar'), 10, 3); } // Autopost for front pages if ($this->data->get_option('wdfb_autopost', 'allow_autopost') && $this->data->get_option('wdfb_autopost', 'allow_frontend_autopost')) { add_action('save_post', array($this, 'publish_post_on_facebook')); if (defined('BP_VERSION')) { if (!$this->data->get_option('wdfb_autopost', "prevent_bp_activity_switch")) { // Semi-auto-publish switch for BuddyPress Activities add_filter('bp_activity_post_form_options', array($this, 'bp_inject_form_checkbox')); } } } // Groups if ($this->data->get_option('wdfb_groups', 'allow_bp_groups_sync')) { if (defined('BP_VERSION')) { add_action('bp_before_group_admin_content', array($this, 'inject_bp_groups_sync')); } } $rpl = $this->replacer->register(); // Allow unhooking actions and post-init behavior. do_action('wdfb-core-hooks_added-public', $this); }
/** * Facebook HTML5 tag format utility function. * Called by dispatcher, @see wdfb_get_fb_plugin_markup for parameters. * @return string */ function wdfb_get_fb_plugin_markup_html5($type, $args) { $markup = ''; switch ($type) { case "like": $markup = '<div class="fb-like" data-href="' . $args['href'] . '" data-send="' . ($args['send'] ? 'true' : 'false') . '" data-layout="' . $args['layout'] . '" data-width="' . $args['width'] . '" data-scheme="' . (!empty($args['scheme']) ? $args['scheme'] : 'light') . '" data-show-faces="true"></div>'; break; case "login-button": $markup = '<div class="fb-login-button" data-scope="' . $args['scope'] . '" data-redirect-url="' . $args['redirect-url'] . '" data-onlogin="******">' . $args['content'] . '</div>'; break; case "comments": $responsive = defined('WDFB_USE_RESPONSIVE_FB_COMMENTS_HACK') && WDFB_USE_RESPONSIVE_FB_COMMENTS_HACK; $markup = '<div class="wdfb-fb_comments"><div class="fb-comments" data-href="' . $args['link'] . '" ' . 'data-xid="' . $args['xid'] . '" ' . 'data-num-posts="' . $args['num_posts'] . '" ' . 'data-width="' . $args['width'] . '" ' . 'data-reverse="' . $args['reverse'] . '" ' . 'data-colorscheme="' . $args['scheme'] . '" ' . ($responsive ? 'data-mobile="false" ' : '') . 'data-publish-feed="true"></div></div>'; if ($responsive) { add_action(wdfb_get_footer_hook(), 'wdfb__responsive_fb_comments_hack_style'); } break; case "activity": $markup = '<div class="fb-activity" data-site="' . $args['url'] . '" data-width="' . $args['width'] . '" data-height="' . $args['height'] . '" data-header="' . $args['show_header'] . '" data-recommendations="' . $args['recommendations'] . '" data-colorscheme="' . $args['color_scheme'] . '" data-linktarget="' . $args['links'] . '"></div>'; break; } return $markup; }