Wordpress 239 charactors of unexpected output error - wordpress

I am new to wordpress. Here is a task for me.
I need to active a plugin that is created already.
Now, when I try to active it, it gives me following error.
The plugin generated 239 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.
So, first thing I did was google. One of the reasong I found was the white-space left behind code somewhere.
So, I followed it and removed blanks from my code. but did not help me out.
Now, I am putting my code herewith this post. Can anyone please help me out. its going really irritating.
<?php
/*
* Plugin Name: Lucky Draw
* Description: Plugin For Lucky Draw Voucher And Spinning
* Author: Techuz Infoweb Pvt. Ltd
*/
/* Die page if access directly from url */
defined('ABSPATH') or die('No script kiddies please!');
ob_start();
/* Runs when plugin is activated */
register_activation_hook(__FILE__, 'luckydraw_install');
/* = Use Wordpress functions in plugin files
---------------------------------------------------- */
if (file_exists(ABSPATH.'wp-load.php')) {
require_once(ABSPATH.'wp-load.php');
}
/* = Include Wordpress datatable class
---------------------------------------------------- */
if(!class_exists('WP_List_Table')){
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}
/* = Setup Tables in database
---------------------------------------------------- */
require_once(plugin_dir_path(__FILE__).'ws_setup.php');
register_activation_hook(__FILE__,'ws_luckydraw_setup_tables');
/* = Include All the plugin pages in ws_register_pages.php file
---------------------------------------------------- */
require_once(plugin_dir_path(__FILE__).'ws_register_pages.php');
/* = Include scripts and styles
---------------------------------------------------- */
add_action('admin_enqueue_scripts','ws_luckydraw_load_scripts');
if(!function_exists('ws_luckydraw_load_scripts')) {
function ws_luckydraw_load_scripts() {
wp_enqueue_script('jquery');
wp_enqueue_media();
wp_enqueue_style('thickbox'); // call to media files in wp
wp_enqueue_script('thickbox');
wp_enqueue_script('media-upload');
wp_enqueue_style('jquery-ui-css', plugins_url('lucky-draw/css/jquery-ui.css'));
wp_enqueue_style('style', plugins_url('lucky-draw/css/ld_style.css'));
wp_enqueue_script('jquery-ui-js', plugins_url('lucky-draw/js/jquery-ui.js'));
wp_enqueue_script('jquery-datetimepicker-script', plugins_url('lucky-draw/js/jquery.datetimepicker.js'));
wp_enqueue_script('jquery-validate-js', plugins_url('lucky-draw/js/jquery.validate.js'));
wp_enqueue_script('common-js', plugins_url('lucky-draw/js/common.js'));
}
}
/* = Luckydraw Deactivation
---------------------------------------------------- */
if(!function_exists('ws_luckydraw_deactivate')):
function ws_luckydraw_deactivate() {
flush_rewrite_rules();
}
endif;
register_deactivation_hook(__FILE__, 'ws_luckydraw_deactivate');
?>
Thanks in advance.....

I dont know why? no ones gonna answer here. however I found one, it was silly mistake.
register_activation_hook(FILE, 'luckydraw_install');
was called twice, and above call was of no use for me. So I have removed above call, and error has gone.

Related

Loss style the style no longer loads wordpress

I don't understand the style bug that I encounter, here is a picture.
Photo of the bug and the console.
This problem comes on mobile and tracker links on PC with the chrome browser.
I encounter it most often on the safari browser, chrome mobile.
I have a child theme here that called the stylesheet here is the code.
Code: 
/**
* Theme functions and definitions
*
* #package HelloElementorChild
*/
/**
* Load child theme css and optional scripts
*
* #return void
*/
function hello_elementor_child_enqueue_scripts()
{
wp_enqueue_style(
'hello-elementor-child-style',
get_stylesheet_directory_uri() . '/style.css',
[
'hello-elementor-theme-style',
],
'1.0.0'
);
}
add_action('wp_enqueue_scripts', 'hello_elementor_child_enqueue_scripts', 20);
I tested to move the jQuery in the head it did not change anything and I call the jQuery by script in WordPress plugin snippets.
```````
`
I'm stalling, I don't know what to look for with this bug.
Thanks in advance for any ideas on how to get around it.

Call to undefined function get_editable_roles()

For some reason, I can't get working the WordPress function get_editable_roles(). Is there a bug with this? Doesn't mind where I add, in the functions.php, in the index.php, in the top, in the bottom. It always gives the undefined function error.
I added this line of code in Twenty Fifteen theme, in a fresh WordPress install and without any plugin:
$role = get_editable_roles();
It give this error:
Error: Call to undefined function get_editable_roles()...
If I load the user.php file before, then it works:
if (!function_exists('get_editable_roles')) {
require_once(ABSPATH . '/wp-admin/includes/user.php');
}
You should consider to load user.php even you are in admin side, especially you have created a custom admin page like options.
if ( ! function_exists( 'get_editable_roles' ) ) {
require_once ABSPATH . 'wp-admin/includes/user.php';
}
$roles = get_editable_roles();
It is also discussed here.
I think the problem is that you're trying to use this function outside the admin section where it isn't loaded.
From the Wordpress documentation:
Notes
The file that defines this function (wp-admin/includes/user.php) is only loaded in the admin sections.
See: https://codex.wordpress.org/Function_Reference/get_editable_roles

Having issue with WordPress wp_enqueue_style

I am building a full design into WordPress for the first time and I am trying to load in stylesheets and script files but all I seem to be getting is the text output of the location.
What I have is below..
wp_enqueue_style('reset', bloginfo('template_url') . '/reset.css');
wp_enqueue_style('style', bloginfo('stylesheet_url'), array('reset'));
wp_enqueue_style('rhino', bloginfo('template_url') . '/rhinoslider-1.05.css', array('reset','style'));
Do I need to put this inside the link tags or something? I thought it would do it all itself; as what's the point loading it that way if it doesn't do it itself? I know it makes sure the same file isn't included twice or something, but if you have to include the link tags yourself and then WP decides not to include the file then you are left with blank link tags!?
Lastly, should I set these up beforehand so I can just call them via their handles? If so, where? functions.php?
Edit: I also tried putting the below in my themes functions.php file but got the same results.
add_action( 'after_setup_theme', 'mmw_new_theme_setup' );
function mmw_new_theme_setup() {
/* Add theme support for post formats. */
add_theme_support( 'post-formats' );
/* Add theme support for post thumbnails. */
add_theme_support( 'post-thumbnails' );
/* Add theme support for automatic feed links. */
add_theme_support( 'automatic-feed-links' );
/* Add theme support for menus. */
add_theme_support( 'menus' );
/* Load style files on the 'wp_enqueue_scripts' action hook. */
add_action( 'wp_enqueue_scripts', 'mmw_new_load_styles' );
}
function mmw_new_load_styles() {
$foo = bloginfo('template_url') . '/reset.css';
$bar = bloginfo('template_url') . '/rhinoslider-1.05.css';
wp_enqueue_style('reset', $foo);
wp_enqueue_style('style', bloginfo('stylesheet_url'), array('reset'));
wp_enqueue_style('rhino', $bar, array('reset','style'));
}
When storing values in a variable via PHP use:
get_bloginfo()
So your new function would now look like:
function mmw_new_load_styles() {
$foo = get_bloginfo('template_url') . '/reset.css';
$bar = get_bloginfo('template_url') . '/rhinoslider-1.05.css';
wp_enqueue_style('reset', $foo);
wp_enqueue_style('style', bloginfo('stylesheet_url'), array('reset'));
wp_enqueue_style('rhino', $bar, array('reset','style'));
}
And be more semantic! It makes code for beginners easier to look at. ($foo could be $resetCssUrl)
I was having similar issues.
The register / enqueue scripts are so that you can globally assign your functions to load in the correct order. You can call them from the page that your working in but it is considered better practice do it this way.
My template has a functions.php but its nealry empty! It sepreates the scripts into 7 subchapters, theme-options, theme-functions, themes-js, etc. Here is my themes.js.php file but this could quite easily placed in your file inside your wp-content/themes/functions.php My themes-js.php file

How do I display all wordpress-posts in a custom xml-sheet?

I'm trying to do it by creating a custom template, but I can't figure out how to do that. Does anyone have any suggestions?
I also need to know how I link to it.
Follow these steps, I wont go into details about how you want to do your XML for the sake of simplicity:
Create a page template file in your current theme folder, like xml_template.php with this code inside:
<?
/*
Template Name: XML Template
*/
$qry = new WP_Query('posts_per_page=-1');
/* PREPARE YOUR XML BEFORE THE LOOP */
/* RUN THE LOOP */
if($qry->have_posts()){
while($qry->have_posts()) {
$qry->the_post();
/* DO WHAT YOU WANT WITH EACH POST */
}
}
/* WHEN THE LOOP IS OVER PREPARE XML FOR OUTPUT */
header('Content-type:text/xml');
/* ECHO OUT THE XML */
?>
Create a page in wordpress and then choose the template "XML Template" for it.
Visit that page and have a look!
Check out the Wordpress Codex for the function get_posts

Fatal error: Call to undefined function load_theme_textdomain()

I do not know if I can ask word press templated questions here. I was trying to add a line to functions.php in order to display images in RSS feeds. However, I missed to add a "/ "at the end of my comment line and my website crashed.
I am getting this error:
Fatal error: Call to undefined function load_theme_textdomain() in /home/content/31/6570531/html/wp-includes/functions.php on line 33
the 33 line of functions.php has this line of code:
load_theme_textdomain( 'btp_theme', get_template_directory().'/languages' );
is there anyone who knows what should I do? I reupload template files but still getting the same error.
this is the part of error I think
/* Initialize translation mechanism */
load_theme_textdomain( 'btp_theme', get_template_directory().'/languages' );
$locale = get_locale();
$locale_file = TEMPLATEPATH . "/languages/$locale.php";
if ( is_readable($locale_file) )
require_once($locale_file);
/* EnableWP Auto Feed Links */
add_theme_support('automatic-feed-links');
/* Enable post thumbnails support */
add_theme_support( 'post-thumbnails' );
/* Enable custom backgrounds support */
add_custom_background();
if ( ! isset( $content_width ) ) $content_width = 593;
I solved my problem and want to share it with you.
You should download a fresh copy of WordPress. Than delete
wp-config.php
and
wp-content directory
from your wordpress copy on your harddrive. These are vital steps in order you to not loose your settings and content.
Than upload the Wordpress files via FTP to your server.

Resources