Column in query should be selected according to value from another column

Assuming I have table1 with following data:

table1

id| coffee_sender | coffee_receiver | received_bag_size | sent_bag_size| price | 21  tux              -1                  m                 -1            45  22  alsa            -1                  -1                 xl            36 23  -1               tux                 l                 -1            51 

And I use the following query:

select t1.* from ( select t.price, t.id from table1 t  where coffee_sender in (tux, alsa)  or coffee_receiver in (tux, alsa) and received_bag_size in (m, xl) or sent_bag_size in (m, xl)) t1 

What i want is to only fetch the rows that have coffee_sender/coffee_receiver AND sent_bag_size/received_bag_size filled with a value (rows that match the following conditions):

coffee_sender = tux, sent_bag_size= xl 

OR

coffee_receiver = tux, received_bag_size= m 

OR

coffee_sender = tux, sent_bag_size = xl AND coffee_receiver = tux, received_bag_size= m 

So id = 21 would be excluded from the example table1.

How can i update the above query for this ? Thank you in advance.

Hide ‘add to cart’ when certain value in dropdown is selected

Need help here please. I am trying to hide the ‘add to cart’ woocommerce button when a user selects a specific item in a dropdown list. I have tried multiple JQuery snippets in both functions.php and through 3rd party plugins but am still struggling to get it to work.

In Functions.php theme file

function load_scripts() { ?>     <script type="text/javascript">     $  (document).ready(function(){         $  (document.getElementsByName("select-1574795073993")).change(function(){             $  ( "select option:selected").each(function(){                 if($  (this).attr("value")=="International"){                     $  (".single_add_to_cart_button").hide();                 }             });         }).change();     });     </script> <?php } add_action('wp_enqueue_scripts', 'load_scripts'); 

Please can someone assist with simple steps to 1) provide correct code, and 2) insert in the woocommerce.com hosted plarform.

Much appreciated!

Are class skills picked before or after your character’s Background is selected?

In the Backgrounds section:

Each background gives a character proficiency in two skills. Skills are described in chapter 7. In addition, most backgrounds give a character proficiency with one or more tools. Tools and tool proficiencies are detailed in chapter 5. If a character would gain the same proficiency from two different sources, he or she can choose a different proficiency of the same kind (skill or tool) instead.

Could a Barbarian character being created, for instance, pick Athletics and Survival as his class skills, and then when selecting a background, pick Outlander (which grants proficiency in these two skills), and then using this rule, instead pick two skills from the whole skill list?

Or is your background chosen before class skill-proficiencies?

Reset sliders to default (zero) when a PopupMenu item is selected

I am setting up a UI with sliders that are enabled or disabled according to the item in a PopupMenu. I have been trying to figure out how to reset the sliders to the default value of zero when I select another item from the PopupMenu. After reading the documentation I think that Refresh should do the trick but I am missing something. It seems that after refresh the sliders need to be updated but I cannot figure out how. Can you help? Please see the mwe below. I am using v 12.1.1.0. Thank you!

BU

(* Initialization section *) dMin = -500; dMax = 500; dStep = 0.1; aMin = 0; aMax = 500; aStep = 0.1;  PopupMenu[Dynamic[tType], {   {0, 0, 1, 0, 0, 0} -> "t1",   {1, 0, 1, 1, 0, 0} -> "t2",   {1, 0, 1, 1, 1, 1} -> "t3",   {1, 1, 1, 1, 1, 1} -> "t4",   {2, 1, 1, 1, 0, 0} -> "t5",   {3, 1, 1, 1, 0, 0} -> "t6",   {0, 1, 1, 1, 0, 0} -> "t7",   {0, 1, 1, 1, 1, 1} -> "t8"}]  Manipulate[Grid[{    {"a", Slider[      Dynamic[aa], {If[tType[[1]] == 3 , 1.5 bb, dMin],        If[tType[[1]] == 2, 1.5 bb, If[1.5 bb <= dMax, dMax, 1.5*dMax]],        dStep}, Enabled -> tType[[1]] > 0,       Appearance -> {Small, "UpArrow", "Labeled"},       Background -> LightBlue, ImageMargins -> 0]},    {"b", Slider[Dynamic[bb], {dMin, dMax, dStep},       Enabled -> tType[[2]] > 0,       Exclusions -> {If[tType[[2]] > 0, 0, None]},       Appearance -> {Small, "UpArrow", "Labeled"},       Background -> LightBlue, ImageMargins -> 0]},(*     excludes zero from types 4 t0 8 *)    {"c", Slider[Dynamic[cc], {dMin, dMax, dStep},       Enabled -> tType[[3]] > 0,       Appearance -> {Small, "UpArrow", "Labeled"},       Background -> LightBlue, ImageMargins -> 0]},    {"d", Slider[Dynamic[dd], {aMin, aMax, aStep},       Enabled -> tType[[4]] > 0,       Appearance -> {Small, "UpArrow", "Labeled"},       Background -> LightBlue, ImageMargins -> 0]},    {"e", Slider[Dynamic[ee], {dMin, dMax, dStep},       Enabled -> tType[[5]] > 0,       Appearance -> {Small, "UpArrow", "Labeled"},       Background -> LightMagenta, ImageMargins -> 0]},    {"f", Slider[Dynamic[ff], {aMin, aMax, aStep},       Enabled -> tType[[6]] > 0,       Appearance -> {Small, "UpArrow", "Labeled"},       Background -> LightMagenta, ImageMargins -> 0]}},   Frame -> Outer, ItemSize -> {{1, 21}}],   Dynamic[tType,    Refresh[{aa = 0, bb = 0, cc = 0, dd = 0, ee = 0, ff = 0},     TrackedSymbols :> {tType}]], AppearanceElements -> None] 

How to prevent XSS attack on selected window.location in javascript

This is my code where i have a userId in a method SwitchUser_Click. I need to prevent or somehow encode the return value from the switchUser_Click as it includes the UserId of a user vulnerable to XSS attack or redirects.

function SwitchUser_Click(containerElement, OnSuccess) {             var selecteduserId = $  ("select", containerElement).val();             var makeDefault = $  (":checkbox", containerElement).is(":checked");             window.location = "Default.aspx?uId=" + selecteduserId + "&userActive=" + (makeDefault ? "1" : "0");             OnSuccess();         } 

The belows code is called from aspx page by using Client.RegisterScript and passing the parameters. This is the only place SwitchUser_Click method is used.

function OpenSwitchUser(UserId,modCode,defUrl) {             defaultUrl = defUrl;             var options =             {                 controlUrl: "~/Controls/SwitchUserDialog.ascx",                 params: { uid:UserId, mod: modCode},                 top: 70,                 width: 600,                 height: 2500,                 OKCallback: SwitchUser_Click,                 InitCallback: SwitchUserDialog_Init,                 cancelCallback: SwitchUser_Close             };             $  .showControlDialog(options);         } 

I want to know how to encode my userId in the SwitchUser_Click method and decode it when its called. Or maybe there is some other way to do this . Thank you

filter default wp_query to show just selected level of child pages in wordpress

I’m working on a site that has a fairly large page structure a few levels deep – in some sections there are a lot of pages.

So I want to have functionality if user choose on select box level 1 then only pages in level 1 will show in below list of pages. if he choose level 2 then only level 2 pages, same go to level 3 level 4 level 5 level 6.

it’s working for top level parent pages when I set query_vars[‘post_parent’] = 0; and I want to have same functionality to show list of level 1 child page,level 2 child pages and so on…

I am stuck on it. please I will be great full if anyone can help me for it. Thanks see screenshot link https://i.stack.imgur.com/EKpy6.png

function level_page_admin_posts_filter( $  query ) {   global $  pagenow;   if ( is_admin() && $  pagenow == 'edit.php' && !empty($  _GET['lavel_pages'])) {       $  level = $  _GET['lavel_pages'];       if($  level == 'parent'){         $  query->query_vars['post_parent'] = 0;       }else        if($  level == 1){                }else       if($  level == 2){        }   } } add_filter( 'parse_query', 'level_page_admin_posts_filter' );  function admin_page_filter_level_pages() {   global $  wpdb;   if (isset($  _GET['post_type']) && $  _GET['post_type'] == 'page') {   $  sql = "SELECT ID, post_title FROM ".$  wpdb->posts." WHERE post_type = 'page' AND post_parent = 0 AND post_status = 'publish' ORDER BY post_title";   $  parent_pages = $  wpdb->get_results($  sql, OBJECT_K);   $  select = '     <select name="lavel_pages">       <option value="parent">Parent Pages</option>       <option value="1">Level 1</option>       <option value="2">Level 2</option>       <option value="3">Level 3</option>       <option value="4">Level 4</option>       ';      $  select .= ' </select>';   echo $  select; } else {   return; } } add_action( 'restrict_manage_posts', 'admin_page_filter_level_pages' ); 

Randomly selected words converted into sentence. Did I lose passphrase strength or gain it?

I got 5 dice and opened EFF’s wordlist, and generated a random five-word passphrase (all letters small with spaces, no punctuation) for my PC.

The words were making up a meaningful scene in my mind, so I made a complete sentence out of the words by adding some more words (like of, from, a, etc.) and punctuation.

I am not able to decide which of the following thoughts is more dominant:

Benefit: I got some punctuation, a single capital letter and more words. So the "strength" of passphrase should increase.

Drawback: The virgin passphrase was quite random (nonsense), but the new sentence has got appreciable "real-world" meaning (sense) to it. It looks like a spam message generated by the method mentioned in this answer.

How to make “formats” dropdown apply to only the selected text?

How can I make the format styles dropdown in the classic editor apply to ONLY the selected text? Right now it is applying to the nearest line break from the selected text, I don’t like that.

Here is the code in my functions.php file:

function add_style_select_buttons( $  buttons ) {     array_unshift( $  buttons, 'styleselect' );     return $  buttons; } // Register our callback to the appropriate filter add_filter( 'mce_buttons_2', 'add_style_select_buttons' ); //add custom styles to the WordPress editor function my_custom_styles( $  init_array ) {        $  style_formats = array(           // These are the custom styles         array(               'title' => 'Fancy Words',               'block' => 'div',               'classes' => 'fancywords',             'wrapper' => true,         )     );       // Insert the array, JSON ENCODED, into 'style_formats'     $  init_array['style_formats'] = json_encode( $  style_formats );        return $  init_array;    }  // Attach callback to 'tiny_mce_before_init'  add_filter( 'tiny_mce_before_init', 'my_custom_styles' ); 

WooComemrce Show selected color beside color variation title and separate Add to cart button from quantity

I need some help doing such changes on my site. First of all, I want to show n selected color label to show beside Color title. and second of all, I want to show Add to cart in a separate row not in the same row with quantity. I am attaching a picture below for the reference. Pardon me if it is a silly question I am learning about WooCoomerce. w