Support » Plugin: List Urls » PHP 5.4.45 unexpected ‘class’ (T_CLASS)

  • When using List URLs plugin and generating list, I get a white page and this appears in the error_log

    [25-Oct-2016 04:31:33 UTC] PHP Parse error: syntax error, unexpected ‘class’ (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or ‘{‘ or ‘$’ in /home/username/public_html/wp-content/plugins/list-urls/vendor/league/csv/src/AbstractCsv.php on line 210

Viewing 3 replies - 1 through 3 (of 3 total)
  • Just encountered the same issue.
    Turns out it’s because the csv library requires at least PHP 5.5.
    Thus, the plugin has the same requirement…
    I’m gonna try another plugin or export the urls manually with some sql queries.

    Easier way to get a simple csv of all published posts and pages : create a php file somewhere in your WP install folder with this content :

    
    <?php
    include 'wp-load.php';
    
    function fetch_posts(){
    	$args = array(
    		'post_type' => 'any',
    		'posts_per_page' => -1,
    		'post_status' => 'publish',
    		'suppress_filters' => false
    	);
    	$posts = new WP_Query($args);
    	$posts = $posts->posts;
    	foreach((array) $posts as $post){
    		switch($post->post_type){
    			case 'revision':
    			case 'nav_menu_item':
    				break;
    			case 'attachment':
    				$permalink = get_attachment_link($post->ID);
    				break;
    			case 'page':
    			case 'post':
    			default:
    				$permalink = get_permalink($post->ID);
    				break;
    		}
    		echo "\n{$post->ID}\t{$post->post_type}\t{$post->post_title}\t{$permalink}";
    	}
    }
    
    header('Content-type:text/plain; charset=utf-8');
    
    echo "ID\tType\tTitle\tPermalink";
    
    // we need all languages if wpml is installed
    if(function_exists('icl_get_languages')){
    	$languages = icl_get_languages('skip_missing=0');
    	foreach((array) $languages as $lang){
    		// change language
    		do_action('wpml_switch_language', $lang['code']);
    		fetch_posts();
    	}
    }
    else {
    	fetch_posts();
    }
    

    Access it directly with your browser (or run it via some cli).

    • This reply was modified 3 years, 11 months ago by hardesfred.
    Plugin Author graphems

    (@graphems)

    Sorry guys, yes it is 5.5 min, I will add it to the readme and update to make sure it doesn’t break anything when 5.5 is not there.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘PHP 5.4.45 unexpected ‘class’ (T_CLASS)’ is closed to new replies.