I have installed the latest Simplepie code (1.2.1) and I am using the demo code they provide:
<?php
require 'simplepie.inc';
$url = 'http://news.google.com/news?ned=us&topic=h&output=rss';
$feed = new SimplePie();
$feed->set_feed_url($url);
$feed->init();
// default starting item
$start = 0;
// default number of items to display. 0 = all
$length = 0;
// if single item, set start to item number and length to 1
if(isset($_GET['item']))
{
$start = $_GET['item'];
$length = 1;
}
// set item link to script uri
$link = $_SERVER['REQUEST_URI'];
// loop through items
foreach($feed->get_items($start,$length) as $key=>$item)
{
// set query string to item number
$queryString = '?item=' . $key;
// if we're displaying a single item, set item link to itself and set query string to nothing
if(isset($_GET['item']))
{
$link = $item->get_link();
$queryString = '';
}
// display item title and date
echo '' . $item->get_title() . '';
echo ' <small>'.$item->get_date().'</small><br>';
// if single item, display content
if(isset($_GET['item']))
{
echo ' <small>'.$item->get_content().'</small><br>';
}
echo '<br>';
}
?>
However, when I load the page in my browser, I get dozens of lines saying:
Deprecated: Assigning the return value of new by reference is deprecated in /home/pliggs/public_html/rss/simplepie.inc on line 7722
Anyone know what's wrong?
I ran their compatibility test and it shows all things have passed.
This is a result of SimplePie's PHP 4 compatibility and is nothing in your code. If you want to stop seeing these errors, exclude E_DEPRECATED from your error_reporting:
error_reporting(E_ALL & ~E_DEPRECATED);
If you'd like to fix the errors themselves, you can grab a copy of SimplePie 1.3-dev (which drops PHP 4 compatibility) from GitHub, although keep in mind this is a development version and is unstable.
You need to find every instance of "=& new" in the code and delete the "&" which is now deprecated. There are approximately 116 occurrences in the code. It has to do with copies and references of object instantiation.
The only occurrence of error_reporting I could find in Version 1.2.1 was this line:
if ((ini_get('error_reporting') & $level) > 0)
This was in simplepie.inc
I'm still not sure how to disable all these warnings short of going with the dev version which I'd prefer not to as I have enough code to debug as is.
Related
Is there any way to determine which Fusion Builder Elements are being currently used on a WordPress site?
I have a lot of the elements enabled for a site I'm working on, and I'd like to disable the ones I don't need. Problem is, it's a full site I've taken on from another developer and I REAAAALLY don't want to have to scour the entire site and check for potentially broken elements every time I disable something.
Is this a functionality somewhere within Avada I'm completely missing and I can't find documented anywhere?
I was thinking of writing a tiny plugin that checks the wp_posts table and searching for [fusion_xxxx] elements and displaying a list of used builder elements. Then I can determine which are used throughout the site.
Is this a bad time for any reason?
I wrote a plugin that will run a query on the DB and display used elements and the number of times each is used. Simple, but I think it gets the job done. I very-well might be missing something very obvious about how the info is stored.
This is done in an ajax call, displayed in the browser in a formatted list, etc.
Anywho, here's the part of the plugin that actually gathers the info:
protected function getElementsFromTable($table, $field, &$element_collection)
{
global $wpdb;
$sql = "SELECT * FROM " . $table . " WHERE `" . $field . "` LIKE '%[/fusion_%';";
$results = $wpdb->get_results($sql);
foreach ($results as $item) {
preg_match_all("/\[\/fusion_(.+?)\]/", $item->{$field}, $elements);
// No results found, bail!
if (!count($elements[1])) {
continue;
}
// Store the results
foreach ($elements[1] as $element) {
if (!array_key_exists('fusion_' . $element, $element_collection)) {
$element_collection["fusion_" . $element] = 1;
} else {
$element_collection["fusion_" . $element]++;
}
}
}
}
arsort($element_collection);
Usage:
$this->getElementsFromTable("wp_posts", "post_conent", $element_collection);
Welcome to use the WordPress template developer allows the addition of servers to watch movies I have some problems are when you add a server and update the article is updated but returns the right empty or not added and then when you delete the server is not deleted I checked the error record and this is the result
[21-Sep-2018 10:42:50 UTC] PHP Warning: array_combine() expects parameter 2 to be array, boolean given in /home3/mysite/public_html/wp-content/themes/movie/functions.php on line 154
File functions.php
https://3bdo.info/functions.zip
The linked zip file seams to be broken so I cannot extract the file.
But in general the error message says, that you have to use two arrays to call array_combine. You seam to try to combine an array (which is like a list) and a boolean (which is like yes/no). And that is not possible.
$android_servers_title2 = servers_get_meta( 'android_download_server_title' );
$android_servers_code2 = servers_get_meta( 'android_download_server_link' );
/* foreach($servers_title as $server_title)
{
echo "<label for='servers_server_title'>Server Title</label>";
echo " <br><input type='text' name='servers_server_title[]' id='servers_server_title' value='" . $server_title . "'><br>";
} */
if($android_servers_title2){
$android_arraye2 = array_combine($android_servers_title2, $android_servers_code2);
}else {
$android_arraye2 = false;
}
This is basically your problem. servers_get_meta is returning 'false' I would imagine. Check that 'android_download_server_link' is set. you may wish to change the if statement code to detect a false
if($android_servers_title2 && $android_servers_code2){
I want to remove the post status count from WordPress edit.php.
My WordPress CMS have more than 500,000 posts. The publish count is loaded every time you open the page. The following query is fired every time.
This makes my Wordpress CMS loading very slow.
SELECT post_status, COUNT( * ) AS num_posts FROM wp_posts WHERE post_type = 'post' GROUP BY post_status
By tracing the code, I've worked up the only solution that I can see.
The filter bulk_post_updated_messages is ONLY called on the edit.php screen.
The counts are not calculated (in class-wp-posts-list-table.php, get_views method) if the global variable $locked_post_status is not empty.
By gluing these two pieces of information together, I've got a solution that you can use by dropping it into your theme's functions.php file:
// Hook this filter, only called on the `edit.php` screen.
// It's not the "correct" filter, but it's the only one we can leverage
// so we're hijacking it a bit.
add_filter('bulk_post_updated_messages', 'suppress_counts', 10, 2);
// We need to let the function "pass through" the intended filter content, so accept the variable $bulk_messages
function suppress_counts($bulk_messages) {
// If the GET "post_type" is not set, then it's the "posts" type
$post_type = (isset($_GET['post_type'])) ? $_GET['post_type'] : 'post';
// List any post types you would like to KEEP counts for in this array
$exclude_post_types = array('page');
// Global in the variable so we can modify it
global $locked_post_status;
// If the post type is not in the "Exclude" list, then set the $locked variable
if ( ! in_array($post_type, $exclude_post_types)) {
$locked_post_status = TRUE;
}
// Don't forget to return this so the filtered content still displays!
return $bulk_messages;
}
i came up with this solution.
//Disable Article Counter - query runs for about 1-2 seconds
add_filter('admin_init', function () {
foreach (get_post_types() as $type) {
$cache_key = _count_posts_cache_key($type, "readable");
$counts = array_fill_keys(get_post_stati(), 1);
wp_cache_set($cache_key, (object)$counts, 'counts');
}
}, -1);
add_action('admin_head', function () {
$css = '<style>';
$css .= '.subsubsub a .count { display: none; }';
$css .= '</style>';
echo $css;
});
the post counter uses the wp-cache, the idea behind this approach is, to prefill the cache with the "correct" object containing 1's (0 would skip the status from being clickable) - at the earliest moment.
it results in all stati being displayed - with 1's and the query is not run et-all
in addition it returns a css snippet to hide the (1)
well I haven't been able to find the problem with my little custom module for a couple of days, I'm hoping some clever and kind person might spot my issue ;)
So I am creating a simple module that runs on a certain view type, this view contains images, the images have alt tags, I want to amend these alt tags by using the url alias and sticking this on the end of the alt tag..
I have successfully found the data in the $view array and I have looped through all image instances and done as said above, I know it has worked because I have printed them out onto the page.
However it is not updating the view on the actual page, the alt tags remain the same... Please excuse my ignorance here as I am learning PHP and multidimensional keyed arrays are taking some time to sink in.
So what is the variable called for the alt tag, an object? I think that's wrong but anyway.. This variable which is ..
$view->result[0]->_field_data['nid']['entity']->field_image_front_menu['und'][0]['alt']
... is being changed, everything seems fine inside the function and I have tried
return $view
but to no avail.
Here is my code in entirety
<?php
function image_alt_tag_alter_views_pre_render(&$view) {
if ($view->name == "we_print_for_menu") {
$path = arg(0) . "/" . arg(1);
$alias = drupal_get_path_alias($path);
// loops through index in array to change each alt tag
for ($i = 0; $i < count($view->result); ++$i) {
$view->result[$i]->_field_data['nid']['entity']->field_image_front_menu['und'][0]['alt'] = $view->result[$i]->_field_data['nid']['entity']->field_image_front_menu['und'][0]['alt'] . $alias;
}
return $view;
?>
<?php
function image_alt_tag_alter_views_post_execute(&$view) {
global $user;
if ($view->name == "we_print_for_menu") {
path = arg(0) . "/" . arg(1);
$alias = drupal_get_path_alias($path);
dsm($view);
for ($i = 0; $i < count($view->result); ++$i) {
$amended_alt = $view->result[$i]->_field_data['nid']['entity']->field_image_front_menu['und'][0]['alt'] . " " . $alias;
$view->result[$i]->_field_data['nid']['entity']->field_image_front_menu['und'][0]['alt'] = $amended_alt;
}
}
}
I have a script which when running standalone as a php works fine. It's a simple output of an rss feed but the rss is generated on the fly by dircaster. When I turn this into a wordpress plugin, however, it fails to work every time.
This is the error which is often given. Pressing refresh sometimes then makes it work.
Warning: array_slice() expects parameter 1 to be array, null given in /home/evilmer/public_html/frome.me/ffm/wp-content/plugins/fromefm-player/fromefm-player-plugin.php on line 50
Warning: Invalid argument supplied for foreach() in /home/evilmer/public_html/frome.me/ffm/wp-content/plugins/fromefm-player/fromefm-player-plugin.php on line 53
This is the code which is generated based on [ffmplayer show=xxx showno=xx]. I have not included the entire shortcode code as I don't think it's neccesary.
include_once(ABSPATH . WPINC . '/rss.php');
$num_items = $showno;
$feedurl = 'http://fromefm.co.uk/archive/dircasterX.php?show='.$show;
$feed = fetch_rss($feedurl);
$items = array_slice ($feed->items, 0, $num_items);
$list = "";
foreach ($items as $item )
{
$title = $item[title];
$mp3link = $item[link];
$description = $item[description];
$list .= "$title - $description</br><audio src='$mp3link' preload='none'> </audio>";}
return "
<script>
audiojs.events.ready(function() {
var as = audiojs.createAll();
});
</script>
$list
";
Line 50 is:
$items = array_slice ($feed->items, 0, $num_items);
And line 53 is
foreach ($items as $item )
I'm convinced that it's just not running the DircasterX.php (dircaster.org) script properly or every time but it seems to work ok when I use it standalone and calling it with magpierss instead of the version (rss.php) which is built into wordpress.
The standalone version is currently here http://www.fromefm.co.uk/popupplayer/five.php?show=homelyremedies&showno=6 Instead of using wordpress shortcode it gets the variables from $_get instead.
There is a demo install of the plugin here (please ignore the js error on fromfmplayer.js as it's unrelated) http://frome.me/ffm/?page_id=48
The warning you got tells you that $feed is null. Probably because fetch_rss($feedurl) didn't its results successfully.