No feed output when working with Friendfeed and Wordpress API? - wordpress

This is probably a Wordpress issue more than a Friendfeed issue but could be either. I have tried to debug with Firebug, wP_DEBUG, and error_log() but no issues have appeared.
I'm trying to initalize a set of ajax-powered feeds (using Friendfeed API) in the middle sidebar on various Wordpress category pages using a conditional statement. I can get one feed to display on one page no problem but when I add the conditional, it no longer displays.
Relevant lines:
function farmball_feed() {
global $post;
if ( is_category('3')) { $category = "farmball";
} elseif ( is_category('4')) { $category = "new-redsox";
} else { $category = "red-sox-on-farmball"; }
$feed = $friendfeed->fetch_room_feed($category, null, 0+($ind*30), 30);
Here is the full plugin code: http://www.pastie.org/private/vja7eisby93e3odh628xg
I call the function within the plugin using the following line in the sidebar-[category].php template file:
<?php if (function_exists('farmball_feed')) { farmball_feed(); } ?>
Here is the full sidebar code: http://pastie.org/private/lgxsdwxja08v93pkmvz3ug
I've checked in with the WP.org forum, MIRC, WP Tavern forum, and Friendfeed forum but no solution yet. I looked into the Developing a Widget codex but this plugin uses a couple other JS files so I don't think making it a custom widget would work. I'm not great with PHP so the answer could be a simple one. Appreciate the help.
Demo site: http://farmball.com/boston

It turned out to be an issue with where the JS plugin was being initialized. We had to add a line of php code to the friendfeed file which linked to the sidebar php code. Instead of using a conditional, we created unique sidebar template files, each calling js on its own. No conditional needed.

Related

Wordpress clear template cache for Page Templates?

I have a CPT custom post type of Books. The single template being used is 'single-books.php'. However, when I make changes to this file, they don't show up in the front-end. There is no browser or server caching.
I tested this by creating a new book post with the slug 'test'. Then, I duplicated the template and renamed it 'single-books-test.php'. As expected, the new book page started loading this template. However, when I made changes to 'single-books-test.php', the new changes won't show up.
Is there any way to clear Wordpress page template cache? Any help will be highly appreciated!
Not sure if this is your case but I’ve just discovered that the template I am using (Nanospace) itself utilizes a WordPress caching mechanism and the page is only re-rendered when I change the page using the WordPress editor.
The caching mechanism consists of two PHP functions: get_transient() and set_transient().
In the particular case of the Nanospace template, I found the get_transient() call in the file wp-content/themes/nanospace/includes/frontend/class-post.php:
$output = get_transient( $cache_key );
if ( ! $output ) {
and changed it to following:
$output = false;
if ( ! $output ) {
My changes are now applied as I expected.

Different header.php for mobile devices on wordpress?

First of all: sorry for my bad English, I'm from Germany.
I've got a big problem in my wordpress homepage with the header on mobile devices.
The site is: www.hd-sign.de
If you open the page on a computer, everything looks fine, but if I open the page on a mobile device, the text box on the left is over the "HD - Sign" text and it looks very bad.
You can see what i mean on "am i responsive".
I installed the Mobile Device Detect Plugin to Wordpress and added this to my custom.css file:
include Mobile_Detect.php;
$detect = new Mobile_Detect;
if( ! $detect->isMobile() {
include "mobile_header.php";
}
else {
include "header.php";
}
But it wont work. For sure I installed the header.php & mobile_header.php (without the boxed text) to my main theme folder.
I tried many different methods in the past 5 hours but I still was not able to fix this problem.
Thank you very much in advance for every answer!
EDIT:
Thanks for every answer, actually i got the following code:
include Mobile_Detect.php;
$detect = new Mobile_Detect;
if( ! $detect->isMobile() ) : {
function get_header( 'mobile' );
}
else : {
function get_header();
endif;
}
Im not sure if this code is correct and absolutely not sure if i have to put the code in the "general-template.php" or in my custom css. Sorry for this stupid question, but i just started working with html and css.
It would be great if someone can tell me where i have to put the (correct?) code!
Thanks!
Name your files like this:
header.php
header-mobile.php
and use WordPress conventions to call your headers like this:
// default
get_header();
// mobile
get_header( 'mobile' );
Other than that, I'd highly recommend looking into responsive web design and media queries. Your header will load once when the page loads for the first time. It won't change when you resize the browser window by using this technique.
Resources:
WordPress function reference for get_header() - http://codex.wordpress.org/Function_Reference/get_header
Try this.
if(!preg_match('/(iPhone|iPod|iPad|Android|BlackBerry)/i', $_SERVER['HTTP_USER_AGENT']))
{
include "mobile_header.php";
}
else
{
include "header.php";
}

Wordpress plugin shortscodes in other plugins?

I'm developing a plugin that creates custom wordpress pages, however I ran into a problem when trying to get shortcodes from other plugins to integrate into my plugin, well more like I couldn't find any info on it.
For example if someone uses my custom page builder and adds a short code [gallery] that is associated with an enabled plugin, I want the shortcode to do it's thing.
Could anyone point me in the right direction for this?
Try wordpress
http://wordpress.org/plugins/synved-shortcodes/
while this plugin let's you integrate shortcodes on every wordpress page , I suppose that you issue is with wordpress functions.php file where you can have a look at , with this plugin installed !
You can check if a shortcode exist before printing it with the function shortcode_exists() (https://codex.wordpress.org/Function_Reference/shortcode_exists)
Example:
<?php
if ( shortcode_exists( 'gallery' ) ) {
// The [gallery] short code exists.
}
?>
Then, if it exist and you want to print that shortcode with PHP code you should use do_shortcode() function (https://developer.wordpress.org/reference/functions/do_shortcode/)
Example:
<?php echo do_shortcode('[gallery]); ?>
Always use in WordPress's in-built
the_content
hook to print your custom page content.
WordPress by default process all shortcodes before outputting any stuff from this hook.
More info can be found here: https://codex.wordpress.org/Function_Reference/the_content

Calling wp_enqueue_media() in a custom theme widget on WordPress 3.5.x cause js error

I am writing a custom widget for my own WordPress theme.
From WordPress 3.5 there is a new Media Uploader instead of the old ThickBox.
My widget used to work fine on WordPress versions older than 3.5, but now the new media uploader prevent the old working behavior.
I added a check in the costructor for the presence of wp_enqueue_media function:
if( function_exists( 'wp_enqueue_media' ) ) {
wp_enqueue_media();
}
but when this part of cose is executed javascript throw an error in the console stopping Js engine:
Uncaught TypeError: Cannot read property 'id' of undefined load-scripts.php:69
I removed all the widget code and reduced it to bare bones... the error is caused by wp_enqueue_media() calls, but I cannot get my head around why and how to fix it.
I also read Wordpress 3.5 custom media upload for your theme options, but there is no mention to this issue
Can anyone point me in the right direction? Is there any documentation available for the the WordPress 3.5 Media Uploader?
It's too late for you now, but might be helpful for other people. I managed to make it work using
add_action( 'admin_enqueue_scripts', 'wp_enqueue_media' );
Hope it helps!
The problem you are experiencing is because you probably put your custom jquery in the header and you didn't registered wordpress jquery. If multiple jquery are defined you will get that error.
My sugestion is you should either remove your jquery script or remove the one from wordpress
function remove_jquery() {
wp_deregister_script('jquery');
//wp_register_script('jquery', ("//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"), false);
}
if(!is_admin()){add_action('init', 'remove_jquery');}
I suggest you use the jquery wordpress provides you, if not, the proper way to enqueue it is to deregister the default one an register your jquery. Just remove the comments from the remove_jquery function.
Also, the above code should go in functions.php
Cheers.
From codex [1], the function wp_enqueue_media( $args ) should be called from 'admin_equeue_scripts' action hook. or later.
Example:
function enqueue_media() {
if( function_exists( 'wp_enqueue_media' ) ) {
wp_enqueue_media();
}
}
add_action('admin_enqueue_scripts', 'enqueue_media');
Hope it helped.
[1]. https://codex.wordpress.org/Function_Reference/wp_enqueue_media
To debug, you need to get the non-minified versions of the js sent to the browser. See the docs:
SCRIPT_DEBUG
SCRIPT_DEBUG is a related constant that will force WordPress to use the "dev" versions of core CSS and Javascript files rather than the minified versions that are normally loaded. This is useful when you are testing modifications to any built-in .js or .css files. Default is false.
define('SCRIPT_DEBUG', true);

Blog page with theme completely different from the main theme?

I have been trying to make my website on Wordpress. I am using Brave Zeenat as my primary and Grido as my blog theme.
I have read many tutorials in places, which discuss how to apply a customized flavour of the main theme on a static page, e.g. Blog. However, the main theme I am using does not appeal to me as a blog theme at all, so I wanted to do something entirely different, so I have tried two methods.
First, I tried to just create a page named Blog and force it to take a theme of my choice using the Page Theme plugin. That worked instantly, but the blog page is empty and would not accept articles of certain categories by default like this.
Second, I tried to not use any plugin at all, and use a custom PHP file instead, which sets some loops and calls a theme. This file blog.php had to be in the main theme directory, otherwise it would not be applicable as a template from the page settings in Wordpress dash.
So I put it with my main theme, but call to load the other theme, like this:
<?php
/*
Template Name: Blog
*/
$paged = get_query_var('paged');
query_posts('cat=0&paged='.$paged);
global $more;
$more = 0;
load_template(WP_CONTENT_DIR . '/themes/grido_v1.0.1/index.php');
?>
Eventually I only want to see category no.9, but for now, I left it as 0, which should display all categories. But when I run this with Page Theme plugin disabled, I get this error: Fatal error: Call to undefined function themify_get() in /var/sites/v/visualdeceptions.info/public_html/wp-content/themes/grido_v1.0.1/index.php on line 10.
Now, although this is a themify error, I am sure if I try to use other premium themes as well, I will encounter very similar errors, because I have only set a custom php file, and no style, header, footer, etc. But I am not sure how to do it.
Try to add getheader() and getfooter() in the code
<?php
/*
Template Name: Blog
*/
get_header(); //HERE
$paged = get_query_var('paged');
query_posts('cat=0&paged='.$paged);
global $more;
$more = 0;
load_template(WP_CONTENT_DIR . '/themes/grido_v1.0.1/index.php');
get_footer(); //HERE
?>

Resources