'; return $content; } /** * Include internal stylesheet. * * @action: wp_head, login_head **/ function style() { if ( file_exists( TEMPLATEPATH . '/fbconnect.css') ){ $css_path = get_template_directory_uri() . '/fbconnect.css?ver='.FBCONNECT_PLUGIN_REVISION; }else{ //$css_path = get_option('siteurl') . '/' . PLUGINDIR . '/fbconnect/fbconnect.css?ver='.FBCONNECT_PLUGIN_REVISION; $css_path = FBCONNECT_PLUGIN_URL . '/fbconnect.css?ver='.FBCONNECT_PLUGIN_REVISION; } echo ''; } /** * Modify comment form. * * @action: comment_form **/ function comment_form() { $fb_user = fb_get_loggedin_user(); if (is_user_logged_in() && $fb_user) { echo ''; echo ''.__('Publish this comment to Facebook', 'fbconnect'); } } /** * Spam up the admin interface with warnings. **/ function admin_notices_plugin_problem_warning() { echo'

'.__('The WordPress fbconnect plugin is not active.', 'fbconnect').''; printf(_('Check %sfbconnect Options%s for a full diagnositic report.', 'fbconnect'), '', ''); echo '

'; } /** * Setup admin menus for fbconnect options and ID management. * * @action: admin_menu **/ function add_admin_panels() { $hookname = add_options_page(__('fbconnect options', 'fbconnect'), __('Facebook Connector', 'fbconnect'), 8, 'global-fbconnect-options', array( 'WPfbConnect_Interface', 'options_page') ); add_action("admin_head-$hookname", array( 'WPfbConnect_Interface', 'js_setup' )); add_action("admin_head-$hookname", array( 'WPfbConnect_Interface', 'style' )); } function register_feed_forms($fb_online_stories,$fb_short_stories_title,$fb_short_stories_body,$fb_full_stories_title,$fb_full_stories_body) { $one_line_stories = $short_stories = $full_stories = array(); $one_line_stories[] = $fb_online_stories; $short_stories[] = array('template_title' => $fb_short_stories_title, 'template_body' => $fb_short_stories_body); $full_stories = array('template_title' => $fb_full_stories_title, 'template_body' => $fb_full_stories_body); $form_id = fb_feed_registerTemplateBundle($one_line_stories,$short_stories,$full_stories); return $form_id; } /* * Display and handle updates from the Admin screen options page. * * @options_page */ function options_page() { global $wp_version, $fbconnect; // if we're posted back an update, let's set the values here if ( isset($_POST['info_update']) ) { check_admin_referer('wp-fbconnect-info_update'); $error = ''; update_option( 'fb_api_key', $_POST['fb_api_key'] ); update_option( 'fb_api_secret', $_POST['fb_api_secret'] ); update_option( 'fb_enable_commentform', isset($_POST['enable_commentform']) ? true : false ); update_option( 'fb_enable_approval', isset($_POST['enable_approval']) ? true : false ); update_option( 'fb_add_post_share', isset($_POST['fb_add_post_share']) ? true : false ); update_option( 'fb_use_ssl', isset($_POST['fb_use_ssl']) ? true : false ); update_option( 'fb_use_fbml', isset($_POST['fb_use_fbml']) ? true : false ); if ($error !== '') { echo '

'.__('At least one of Facebook Connector options was NOT updated', 'fbconnect').''.$error.'

'; } else { echo '

'.__('Facebook Connector options updated', 'fbconnect').'

'; } }elseif (isset($_POST['template_update'])){ check_admin_referer('wp-fbconnect-info_update'); $error = ''; update_option( 'fb_online_stories', $_POST['fb_online_stories'] ); update_option( 'fb_short_stories_title', $_POST['fb_short_stories_title'] ); update_option( 'fb_short_stories_body', $_POST['fb_short_stories_body'] ); update_option( 'fb_full_stories_title', $_POST['fb_full_stories_title'] ); update_option( 'fb_full_stories_body', $_POST['fb_full_stories_body'] ); $templatesId = WPfbConnect_Interface::register_feed_forms($_POST['fb_online_stories'],$_POST['fb_short_stories_title'],$_POST['fb_short_stories_body'], $_POST['fb_full_stories_title'], $_POST['fb_full_stories_body']); if ($templatesId!=""){ update_option( 'fb_templates_id', $templatesId ); }else{ $error = " "; } if ($error !== '') { echo '

'.__('Error updating Facebook templates!', 'fbconnect').''.$error.'

'; } else { echo '

'.__('Facebook templates updated! Templates ID:'.$templatesId, 'fbconnect').'

'; } }elseif ( isset($_REQUEST['action']) ) { switch($_REQUEST['action']) { case 'delete_template' : check_admin_referer('wp-fbconnect-info_delete_template'); fb_feed_deactivateTemplateBundleByID($_REQUEST['template_id']); $fb_templates_id = get_option('fb_templates_id'); if ($_REQUEST['template_id'] == $fb_templates_id){ update_option( 'fb_templates_id', "" ); } echo '

Facebook template removed:'.$_REQUEST['template_id'].'

'; break; case 'activate_template' : check_admin_referer('wp-fbconnect-info_activate_template'); $template = fb_feed_getRegisteredTemplateBundleByID($_REQUEST['template_id']); if (isset($template) && $template!="" ){ update_option( 'fb_templates_id', $_REQUEST['template_id'] ); update_option( 'fb_online_stories', $template["one_line_story_templates"][0] ); update_option( 'fb_short_stories_title', $template["short_story_templates"][0]["template_title"] ); update_option( 'fb_short_stories_body', $template["short_story_templates"][0]["template_body"] ); update_option( 'fb_full_stories_title', $template["full_story_templates"][0]["template_title"] ); update_option( 'fb_full_stories_body', $template["full_story_templates"][0]["template_body"] ); } break; } } // Display the options page form $siteurl = get_option('home'); if( substr( $siteurl, -1, 1 ) !== '/' ) $siteurl .= '/'; ?>

/>

/>

/>

/>

'.__('No active Facebook template, please activate a template or create a new one!', 'fbconnect').''.$error.'

'; }else if ($fb_templates_id == ''){ echo '

'.__('Templates not synchronized with Facebook, write the templates text and press create templates!', 'fbconnect').''.$error.'

'; } else { echo '

'.__('Active Facebook template ID:', 'fbconnect').$fb_templates_id.'

'; } if (isset($templates) && $templates!="" ){ foreach ($templates as $template){ echo "
".__('Template ID:', 'fbconnect').$template["template_bundle_id"].' '.__('Activate template', 'fbconnect').' '; echo ''.__('Delete template', 'fbconnect').''; if ($fb_templates_id == $template["template_bundle_id"]){ echo ' <-'.__('Active Facebook template', 'fbconnect').''; } echo "
".__('One line story:', 'fbconnect').$template["one_line_story_templates"][0]; echo "
".__('Short story title:', 'fbconnect').$template["short_story_templates"][0]["template_title"]; echo "
".__('Short story body:', 'fbconnect').$template["short_story_templates"][0]["template_body"]; echo "
".__('Full story title:', 'fbconnect').$template["full_story_template"]["template_title"]; echo "
".__('Full story body:', 'fbconnect').$template["full_story_template"]["template_body"]; echo "
"; } } //print_r($templates); $fb_online_stories = get_option('fb_online_stories'); if (!$fb_online_stories){ $fb_online_stories = '{*actor*} commented on {*blogname*}, post title: {*post_title*}, {*body_short*} '; } $fb_short_stories_title = get_option('fb_short_stories_title'); if (!$fb_short_stories_title){ $fb_short_stories_title = '{*actor*} commented on {*blogname*}, post title: {*post_title*} '; } $fb_short_stories_body = get_option('fb_short_stories_body'); if (!$fb_short_stories_body){ $fb_short_stories_body = '{*body_short*}'; } $fb_full_stories_title = get_option('fb_full_stories_title'); if (!$fb_full_stories_title){ $fb_full_stories_title = '{*actor*} commented on {*blogname*}, post title: {*post_title*} '; } $fb_full_stories_body = get_option('fb_full_stories_body'); if (!$fb_full_stories_body){ $fb_full_stories_body = '{*body*}'; } ?>