ace0930
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: wp dropdown categories not showing selected option@bcworkz I think I get your point now…But if the
term_id
actually represents the term name, shouldn’t it be able to find it too? Like if 123 (term_id
) represent the term namefish
, “123 = fish”, it cannot be found in this way?I mean
?type=fish
is also looking for posts with the term namefish
,?type=123
is also looking for posts with the term namefish
. And 123 represents fish, which means 123 = fish.If not, why does WordPress still set the default value to
term_id
?
Also if not, at least there should be a short explanation or reminder for this?Forum: Developing with WordPress
In reply to: wp dropdown categories not showing selected option@bcworkz Your explanation is detailed but I’m still not getting the idea. Or maybe you misunderstood the question…
Let’s say we create a new
term
called ‘fish’ for the defaultcategory
. Now this term has an ID number representing it, right? This is called theterm_id
.If the default value for
value_field
isterm_id
, it should still be able to be found? Because theterm_id
is equal to the term ‘fish’?The second question is if I use
name
for thevalue_field
, what isname
actually populated? Is it the wordfish
being populated as the option value? Because thename
is assigned with the taxonomy ID (in the example, it’s ‘type’). It makes make so confused if thevalue_field
isname
. Basically, it means all the option values become the word ‘type’ or it means the option values become the term name of the taxonomy.Forum: Developing with WordPress
In reply to: Best way to remove widgets from the dashboard@diondesigns Genius! But I think it’s hard to remove the notices because they are using
include_once
inside a function withadd_action
. The problem is that there are other codes inside that function which causes me cannot just remove that withremove_action
because it gonna broke the plugin. I am just afraid it’s not a good idea to change the others’ plugin code directly by another/my plugin.Forum: Developing with WordPress
In reply to: Best way to remove widgets from the dashboard@diondesigns What is the bloated code you are referring to? Is the below code bloated?
add_action('wp_dashboard_setup', 'wpdocs_remove_dashboard_widgets'); function wpdocs_remove_dashboard_widgets(){ remove_meta_box('dashboard_quick_press', 'dashboard', 'side'); }
Forum: Developing with WordPress
In reply to: wp dropdown categories not showing selected option@bcworkz I see, if I already set the name to
'type'
without setting thevalue_field
, what should be theterm_id
? Isterm_id
the ID oforange
andapple
?Forum: Developing with WordPress
In reply to: has_shortcode cannot catch gallery@bcworkz That’s what I’m looking for! Thank you so much!
Forum: Developing with WordPress
In reply to: has_shortcode cannot catch gallery@bcworkz Thanks, this is working. May I know how you find this
<!-- wp:gallery
?Because in the future I might want to check if there is some other Gutenberg block in the content, but I do not know the specific string/keyword to search for.
Forum: Developing with WordPress
In reply to: Custom filter with custom taxonomyI found the problem, it should be
'taxonomy' => 'type'
.Forum: Developing with WordPress
In reply to: add shortcode for form@sterndata There is an HTML form element only in
form.php
. Now I understand the concept, I need to return the HTML rather than directlyrequire
it. Many thanks.Forum: Fixing WordPress
In reply to: bug with wpdb::insertI found that the problem is not the
wpdb::insert
but theisset()
. I should use!empty
to check becauseisset()
return true. (the variable is defined and not null)Forum: Developing with WordPress
In reply to: WordPress get all DB table column value as arrayI found a solution:
$data = $wpdb -> get_col ( $wpdb -> prepare("SELECT name FROM $able_name" ) );
Can anyone confirm if this is the best solution?
Forum: Developing with WordPress
In reply to: Purpose of using esc_urlI totally see your point, I think no one would be more professional than a WordPress moderator. I’ll take your advice to wear the belt. Thank you so much.
Forum: Developing with WordPress
In reply to: Purpose of using esc_url@bcworkz Hi, because
get_template_directory_url()
is generated by WordPress and I can assume it’s safe?would not need an escape function because the URL is generated entirely by WordPress functions
https://stackoverflow.com/a/30583251/19507498
And I myself wrote the last part of the URL
'/someText'
, therefore it is safe too? Because nothing is generated at this point.Any time you’re accepting potentially unsafe data, it is important to validate or sanitize it.
https://developer.www.ads-software.com/themes/theme-security/data-sanitization-escaping/
But here I’m not receiving/accepting any data. That’s the reason I don’t understand why I need to use
esc_url
withecho get_template_directory_url . '/someText'
. Is it just an old habit from people?Forum: Developing with WordPress
In reply to: WordPress sanitize tel@kaavyaiyer Noted with thanks!
Forum: Developing with WordPress
In reply to: WordPress form handling with admin-ajax.then( data => { console.log(data) }
is the message returns from the server and not the message sent to the server.