lundi 29 décembre 2014

Getting error while trying to use custom comment function


I'm trying to write a function that will allow me more control over the display of comments on a post page. However I'm confused about how to set it up so WordPress can use it. right now I get the following error:



Warning: call_user_func() expects parameter 1 to be a valid callback, function 'custom_comments()' not found or invalid function name in /Users/Brent/Desktop/Web Design/WP Playground/wordpress/wp-includes/comment-template.php on line 1711



Here is the call to the function:



<div class="comment-list">
<?php
wp_list_comments('type=comment&callback=custom_comments()');
?>
</div><!-- .comment-list -->


And here is what that section of my functions.php file looks like:



add_action('load_comments', 'custom_comments');

function custom_comments($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
?>

<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">

<div class="comment-intro">
<em>commented on</em>
<a class="comment-permalink" href="<?php echo htmlspecialchars(get_comment_link($comment->comment_ID)) ?>"><?php printf(__('%1$s'), get_comment_date(), get_comment_time()) ?></a>
<em>by</em>
<?php printf(__('%s'), get_comment_author_link()) ?>
</div>

<?php if ($comment->comment_approved == '0') : ?>
<em><php _e('Your comment is awaiting moderation.') ?></em><br />
<?php endif; ?>

<?php comment_text(); ?>

<div class="reply">
<?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
</div>

<?php } ?>


Could anyone tell me what I'm doing wrong here to get this error? I know from my research on this issue that sometimes you need to remove_action from another function that may be conflicting with this function, but I'm not even sure I'm calling this function correctly. Please help, I'm having a hard time finding good resources on how to use a custom comment function.


This is the only good resource I've found so I've been following this but it doesn't say anything about the errors: Custom Comments HTML Output


When I googled the error I found this page slightly helpful, but I haven't been able to identify the culprit function: wordpress.org


I've checked out a few other questions on here but they mostly seem to be asking about other specific problems. Help is greatly GREATLY appreciated!





Update Term Description in Admin Panel


I've replaced the default description with a Rich Editor ( wp_editor ) using the {$taxonomy}_edit_form_fields hook and saving them using the edited_{$taxonomy} hook. Originally, I thought I could use that same hook, check if my editor had content, then use wp_update_term to save it into the actual term description. I ended up running into a infinite loop as it turns out that wp_update_term actually also runs edited_{$taxonomy} and thus calls itself again and again...


What would be a good way to circumvent this problem? Is there a filter the the form update runes that wp_update_term does not?





Using two permalinks for one post


Using two permalinks for one post


I am developing a wordpress website for a client, the client want to show 2 separate templaes for post details the scenario will be.


user clicks on post and our default single.php will load up, there have a play button when user click on play button then instead of post name in permalink I want to add /play/post-name and need to load second template for that.


searched on internet and found some suggestions like Maintaining two permalink structures and https://wordpress.org/support/topic/multiple-posts-in-1-permalink but these are not working and also these are trying to add at the end of the link but i need it to before post-name


any help will be appreciated.


thanks





How to throw error to user when saving post


I made a custom post type and on saving its additional data I want to check if I a published post exists by its name. It works alright if there is, but I would like to throw some notice if article is not found.



$post_exists = $wpdb->get_row("SELECT post_name FROM wp_posts WHERE post_name = '" . $_POST['article_name'] . "' AND post_type = 'post'", 'ARRAY_A');
if($post_exists)
update_post_meta($id, 'article_name', strip_tags($_POST['article_name']));
else
???


I noticed there is http://codex.wordpress.org/Class_Reference/WP_Error but I dont think that is what I want since debugging is set to false?. Error could be anything - some usual notice would be fine, but even simple javascript alert could be good. Currently it tells me that the post is saved with green lights which doesnt seem right http://s1.postimg.org/kmjjjvuvj/image.jpg





How to change Disqus "count comments" underline color


I try to change Count comments underline color but it won't change


i used this code



.nav-primary>ul>li.active>a:after {
background: #69bd43 !important;
}


But no change


See below screen shot


enter image description here





problem by dispaly inserted form


i've build a form and insert it's data into custom db by $wpdb.


when i click on submit button, page reloaded and one row add to db but not any thing display in website.


you can see it at: my site link


my insert code is:



function insert_form() {

global $wpdb;
$table_name = $wpdb->prefix . "food_resarved";
$alibaba = $wpdb->insert( $table_name, array('id'=>'','user_id'=> wp_get_current_user()->ID,'name'=> wp_get_current_user()->user_firstname,
'lastname'=> wp_get_current_user()->user_lastname ,'post_title'=> $_POST['post_title'],'food_selected'=> $_POST['food'] ,
'guest_number'=>$_POST['guest_food'],'email'=> wp_get_current_user()->user_email ), array( '%d', '%s', '%s' , '%s' , '%s' , '%s' , '%s', '%s' ) );


if ( !$alibaba ) { $mylink = $wpdb->get_results( "select * from wp_food_resarved where user_id like '".$curent_user."' AND post_title like '".$abcde."' "); foreach ($mylink as $posta){ echo ''; echo ' شما '; echo $posta->food_selected; echo ' سفارش داده‌اید '; echo ''; } } else {echo "Die";} }





Using AJAX for dynamic settings pages


I have a settings page like ...



add_options_page ( 'XXX', 'XXX', 'manage_options', 'xxx_plugin', 'xxx_options_page' );

function xxx_options_page() { ?>
<div class="wrap">
<h2><?php _e('XXX Settings', 'xxx'); ?> </h2>

<form action="options.php" method="post">
<?php settings_fields('xxx_plugin_options'); ?>
<?php $options = get_option('xxx_options'); ?>
<?php $t = xxx_get...; ?>
<table class="form-table">

<select name='xxx_options[foobar]'>
<?php foreach($t as $key => $value) { ?>
<option value='<?php echo $key ?>' <?php selected($key, $options['xxx']); ?>><?php echo $value ?></option>
<?php } ?>
</select>
// ... more elements, submit-button, ...
</form>
<?php } ?>


I need to add another select-element, thoose values depends on the selection of the first select-element.


For example: First select-element: Select Country -> Second select element: Select states of selected country -> Third select element: Select cities of selected state.


I think, I cannot do this without Ajax, but I did not found some matching example or an tutorial how to do that with WP and Ajax. Any ideas? Any examples? TIA!