default callback function in wp_list_comments

The wp_list_comments() function uses the HTML comment list class Walker_Comment by default: A single comment is then displayed with the Walker_Comment::comment() method (#source). If the comment format is HTML5 then the Walker_Comment::html5_comment() is used instead (#source). The pingbacks are rendered with the Walker_Comment::ping() method (#source).

How to validate register settings array

Personally I’d do it the same way, since it seems to be the only point where you can examine user input and validate it. Also, heavily borrowing from code sample in this excellent article: function wpPartValidate_settings( $input ) { if ( check_admin_referer( ‘wpPart_nonce_field’, ‘wpPart_nonce_verify_adm’ ) ) { // Create our array for storing the validated … Read more

settings API: how to create a multi checkbox with blog categories?

I had the same problem, and here what works for me: function journal_check_cats_callback() { $options = get_option(‘journal_theme_blog_2_col’); $pag = journal_theme_blog_2_col; $_cats = get_terms( ‘category’ ); $html=””; foreach ($_cats as $term) { $checked = in_array($term->term_id, $options) ? ‘checked=”checked”‘ : ”; $html .= sprintf( ‘<input type=”checkbox” id=”%1$s[%2$s]” name=”%1$s[]” value=”%2$s” %3$s />’, $pag, $term->term_id, $checked ); $html .= … Read more

Callback URL in WordPress

That’s pretty simple, just use your website home url 🙂 After that, just fire an action when the page is loaded via POST HTTP method and hook with a callback. add_action( ‘wp_loaded’, function() { if ( $_SERVER[‘REQUEST_METHOD’] === ‘POST’ ) { // fire the custom action do_action(‘onchangeapi’, new PostListener($_POST)); } } ); And now the … Read more

How can one utilize a variable as a callback function name for add_settings_field

Do not use different callbacks, use the the sixth parameter for add_settings_field() instead. That is an array, and you can pass any data to the callback here. Example: foreach( $theOptions as $k => $v ) { add_settings_field( $k, $v, ‘my_callback’, $the_options, $the_group, array ( ‘special’ => $k ) ); } function my_callback( $args ) { … Read more

How to use wp_send_json_error?

wp_send_json_error( ‘Error: Invalid data!’ ) Will echoes a JSON string: {“success”:false,”data”:”Error: Invalid data!”} The nice thing about wp_send_json_error() is, the parameter could also be a WP_Error object. As opposed to wp_send_json_success( ‘Everything okay.’ ) which echoes this JSON string: {“success”:true,”data”:”Everything okay.”} Both rely internally on wp_send_json() to echo the JSON data properly and die() afterwards. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)