blank page
-
Hi Greg,
Hope you are good.
I have an issue, when i post an ad on the website provided i get a blank page after publishing, please help solve this.
The page I need help with: [log in to see the link]
-
Hi, in your wp-config.php add line
define("WP_DEBUG", true);
then try posting an Ad again, then aside of blank page you should also see an error message which you can copy and paste here, i should be able to help then.I have added the line define(“WP_DEBUG”, true); and no error showing
Yesterday i had an issue with the site too many redirects and after it was fixed this is the problem that came up
Greg the problem is the functions.php for wp-adverts i have added, once i remove that it works.
Can you know the issue, am unable to figure it out.Below is the code
add_filter( “adverts_form_load”, “customize_adverts_add_sarahagordon” );
function customize_adverts_add_sarahagordon( $form ) {
if( $form[‘name’] != “advert” ) {
return $form;
}
foreach( $form[“field”] as $key => $field ) {
if( $field[“name”] == “_contact_information” ) {
$form[“field”][$key][“label”] = “Submit an ad”;
}
}
return $form;
}add_filter(“pending_advert”, “on_pending_advert”);
function on_pending_advert($id, $post) {
wp_mail(get_option(“admin_email”), “New Pending Ad”, “New Pending Ad”);
}// The code below you can paste in your theme functions.php or create
// new plugin and paste the code there.add_filter( ‘adverts_form_load’, ‘search_by_price_form_load’ );
add_filter( ‘adverts_list_query’, ‘search_by_price_query’ );/**
* Adds price min and max fields into search form in [adverts_list].
*
* @param array $form Search form scheme
* @return array Customized search form scheme
*/
function search_by_price_form_load( $form ) {if( $form[‘name’] != ‘search’ ) {
return $form;
}wp_enqueue_script( ‘adverts-auto-numeric’ );
$form[‘field’][] = array(
“name” => “price_min”,
“type” => “adverts_field_text”,
“class” => “adverts-filter-money”,
“order” => 20,
“label” => “”,
“placeholder” => “Price min.”,
“meta” => array(
“search_group” => “visible”,
“search_type” => “half”
)
);$form[‘field’][] = array(
“name” => “price_max”,
“type” => “adverts_field_text”,
“class” => “adverts-filter-money”,
“order” => 20,
“label” => “”,
“placeholder” => “Price max.”,
“meta” => array(
“search_group” => “visible”,
“search_type” => “half”
)
);return $form;
}/**
* Adds search by price params to WP_Query
*
* The query is modified only if $_GET[‘price_min’] or $_GET[‘price_max’]
* is greater than 0.
*
* @param array $args WP_Query args
* @return array Modified WP_Query args
*/
function search_by_price_query( $args ) {if( adverts_request( ‘price_min’ ) ) {
$args[“meta_query”][] = array(
‘key’ => ‘adverts_price’,
‘value’ => adverts_filter_money( adverts_request( ‘price_min’ ) ),
‘compare’ => ‘>=’,
‘type’ => ‘DECIMAL(12,2)’
);
}if( adverts_request( ‘price_max’ ) ) {
$args[“meta_query”][] = array(
‘key’ => ‘adverts_price’,
‘value’ => adverts_filter_money( adverts_request( ‘price_max’ ) ),
‘compare’ => ‘<=’,
‘type’ => ‘DECIMAL(12,2)’
);
}return $args;
}add_filter( “adverts_form_load”, “customize_adverts_search” );
function customize_adverts_search( $form ) {
if( $form[‘name’] != “search” ) {
return $form;
}
foreach( $form[“field”] as $key => $field ) {
if( $field[“name”] == “query” ) {
$form[“field”][$key][“attr”][“placeholder”] = __(“Looking for …”, “adverts”);
}
}
return $form;
}add_filter( “adverts_form_load”, “customize_adverts_add” );
function customize_adverts_add( $form ) {
if( $form[‘name’] != “advert” ) {
return $form;
}
foreach( $form[“field”] as $key => $field ) {
if( $field[“name”] == “advert_category” ) {
$form[“field”][$key][“max_choices”] = 1;
$form[“field”][$key][“validator”][] = array( “name”=> “is_required” );
}
}
return $form;
}add_filter( ‘adverts_form_load’, ‘search_by_category_form_load’ );
/**
* Adds category dropdown into search form in [adverts_list].
*
* @param array $form Search form scheme
* @return array Customized search form scheme
*/
function search_by_category_form_load( $form ) {if( $form[‘name’] != ‘search’ ) {
return $form;
}
$form[‘field’][] = array(
“name” => “advert_category”,
“type” => “adverts_field_select”,
“order” => 20,
“label” => __(“Category”, “adverts”),
“max_choices” => 10,
“options” => array(),
“options_callback” => “adverts_taxonomies”,
“meta” => array(
“search_group” => “visible”,
“search_type” => “full”
)
);
return $form;
}add_filter( ‘adverts_list_query’, ‘search_by_category_query’ );
/**
* Adds tax_query param to WP_Query
*
* The tax_query is added only if it is in $_GET[‘advert_category’]
*
* @param array $args WP_Query args
* @return array Modified WP_Query args
*/
function search_by_category_query( $args ) {if( ! adverts_request( “advert_category” ) ) {
return $args;
}$args[“tax_query”] = array(
array(
‘taxonomy’ => ‘advert_category’,
‘field’ => ‘term_id’,
‘terms’ => adverts_request( “advert_category” ),
),
);return $args;
}add_filter( “adverts_manage_moderate”, “__return_true” );
// Kenya Price Symbol
// The code below you can paste in your theme functions.php or create
// new plugin and paste the code there.
add_filter(“adverts_currency_list”, “add_adverts_currency”);
/**
* Add new currency to the list
*
* @var $list Array list of currencies
* @return Array updated list of currencies
*/
function add_adverts_currency($list) {$list[] = array(
“code”=>”Ksh”, // ISO 4217 currency code, see https://en.wikipedia.org/wiki/ISO_4217
“sign”=>”Ksh “, // currency prefix or postfix
“label”=>”Kenya Shillings” // currency long name
);return $list;
}
add_filter( “adverts_form_load”, “remove_account_field” );
function remove_account_field( $form ) {
if( $form[‘name’] != “advert” ) {
return $form;
}
foreach( $form[“field”] as $key => $field ) {
if( $field[“name”] == “_adverts_account” ) {
unset( $form[“field”][$key] );
}
}
return $form;
}
// refresh button
add_action( “init”, “my_init”, 1000 );
function my_init() {
remove_action( “adverts_sh_manage_actions_more”, “adext_payments_action_renew” );
add_action( “adverts_sh_manage_actions_after”, “adext_payments_action_renew” );
}
// other user ads
/**
Plugin Name: WPAdverts Snippets – Ads By Author
Version: 1.0
Author: Greg Winiarski
Description: Links “Posted By” on Ad details page, to page which displays all active ads posted by this author. Note this plugin requires WPAdverts 1.0.5 in order to work.
*/
// The code below you can paste in your theme functions.php or create
// new plugin and paste the code there.
add_action( “wp”, “ads_by_author_init”, 50 );
/**
* Registers “Ads By Author” filter and actions.
*
* It does two things:
* – replaces “by John Doe” on Ad details with link to all user Ads
* – if current page is default Ads list and GET param “posted_by” is provided
* then this function will modify [adverts_list] shortcode to include user
* info above Ads list.
*
* @since 1.0
*/
function ads_by_author_init() {
add_filter( “adverts_tpl_single_posted_by”, “ads_by_author_tpl_single_posted_by”, 10, 2 );
if( is_page( adverts_config( ‘ads_list_id’ ) ) && is_numeric( adverts_request( “posted_by” ) ) ) {remove_shortcode( “adverts_list” );
add_shortcode( “adverts_list”, “ads_by_author_list” );add_filter( “adverts_list_pagination_base”, “ads_by_author_pagination_base” );
add_filter( “adverts_list_query”, “ads_by_author_query” );
}
}
/**
* Generates HTML for [adverts_list] shortcode
*
* This function replaces default [adverts_list] callback and
* adds author header before the listings.
*
* @param array $atts Shorcode attributes
* @since 1.0
* @return string Fully formatted HTML for adverts list
*/
function ads_by_author_list( $params ) {
$html = “”;
$params[“search_bar”] = “disabled”;
$author = get_user_by( “id”, adverts_request( “posted_by” ) );
ob_start();
?>
<style type=”text/css”>
.ads-by-author.adverts-options {
padding: 0.5em 1em;
}
.ads-by-author.adverts-options .author-logo {
float: left;
height: 48px;
width: 64px;
}
.ads-by-author.adverts-options .author-logo > img {
border-radius: 50%;
}
.ads-by-author.adverts-options .author-data {
line-height: 24px;
}
</style>
<div class=”ads-by-author adverts-options”>
<div class=”author-logo”>
<?php echo get_avatar( $author->user_email, 48 ) ?>
</div>
<div class=”author-data”>
<?php esc_html_e( $author->display_name ) ?><br/>
<?php esc_html_e( date_i18n( get_option( “date_format” ), strtotime( $author->user_registered ) ) ) ?>
</div>
</div>
<?php
$html.= ob_get_clean();
$html.= shortcode_adverts_list( $params );return $html;
}
/**
* Changes pagination base.
*
* This function adds “posted_by” param to the default
* pagination URL so it is possible to paginate over
* user submitted ads.
*
* @see adverts_list_pagination_base filter in wpadverts/includes/shortcodes.php
*
* @param string $pbase Default pagination base
* @since 1.0
* @return string Updated pagination base
*/
function ads_by_author_pagination_base( $pbase ) {
$pbase = get_the_permalink();
$glue = stripos( $pbase, ‘?’ ) ? ‘&’ : ‘?’;return $pbase . $glue . “posted_by=” . intval( adverts_request( “posted_by” ) ) . ‘%_%’;
}
/**
* Adds “author” param to [adverts_list] WP_Query.
*
* This function filters Ads by “author” param (provided in $_GET[‘posted_by’]),
* it is applied using “adverts_list_query” filter
*
* @see adverts_list_query filter in wpadverts/includes/shortcodes.php
*
* @param string $pbase Default pagination base
* @since 1.0
* @return string Updated pagination base
*/
function ads_by_author_query( $args ) {
$args[“author”] = intval( adverts_request( “posted_by” ) );
return $args;
}
/**
* Replaces user name with link to all user ads.
*
* If user who posted an Ad is registered WP user, then the “By John Doe” text
* on Ad details page is replaced with link to all user Ads.
*
* This change is applied using adverts_tpl_single_posted_by filter.
*
* @see adverts_tpl_single_posted_by filter in wpadverts/templates/single.php
*
* @param string $pbase Default pagination base
* @since 1.0
* @return string Updated pagination base
*/
function ads_by_author_tpl_single_posted_by( $name, $post_id ) {$post = get_post( $post_id );
$person = get_post_meta($post_id, ‘adverts_person’, true);if( $post->post_author ) {
include_once ADVERTS_PATH . “/includes/class-html.php”;$link = get_permalink( adverts_config( ‘ads_list_id’ ) );
$glue = stripos( $link, ‘?’ ) ? ‘&’ : ‘?’;$person = new Adverts_Html( “a”, array(
“href” => $link . $glue . “posted_by=” . $post->post_author
), $person);
}return sprintf( __(“by %s“, “adverts”), $person );
}// character limits
add_filter( “adverts_form_load”, “limit_title_and_location_length” );
function limit_title_and_location_length( $form ) {
if( $form[‘name’] != “advert” ) {
return $form;
}
foreach( $form[“field”] as $key => $field ) {
if( $field[“name”] == “post_title” ) {
$form[“field”][$key][“validator”][] = array(
“name” => “string_length”,
“params” => array( “min” => 10, “max” => 60 )
);
}
if( $field[“name”] == “adverts_location” ) {
$form[“field”][$key][“validator”][] = array(
“name” => “string_length”,
“params” => array( “min” => 5, “max” => 40 )
);
}
}
return $form;
}Here is the problem Greg,
Once i add this code it shows a blank page after i submit an ad, whats the problem with the code
add_filter( “adverts_form_load”, “customize_adverts_add_sarahagordon” );
function customize_adverts_add_sarahagordon( $form ) {
if( $form[‘name’] != “advert” ) {
return $form;
}
foreach( $form[“field”] as $key => $field ) {
if( $field[“name”] == “_contact_information” ) {
$form[“field”][$key][“label”] = “Submit an ad”;
}
}
return $form;
}add_filter(“pending_advert”, “on_pending_advert”);
function on_pending_advert($id, $post) {
wp_mail(get_option(“admin_email”), “New Pending Ad”, “New Pending Ad”);
}I am not sure, the code itself looks fine, but it would be best if you would paste it here inside the code tag (so it will display here formatted as code not text) then i could tell for sure.
If you do not see any error, you can also ask your hosting tech support to email you an error_log file (or to tell you where the file is located).
- The topic ‘blank page’ is closed to new replies.