Settings API: Setting default option via ‘get_option’ fails

  1. All my options are stored in one array test_hs_options
  2. I have select list settings field ( test_hs_options['duration_months'] ) which stores the selected month (1-12).
  3. For this settings field, I would like to set a default option at 5.
  4. All my attempts at setting the default have failed.
  5. What am I missing?
// Callback for displaying sfield_select_duration. function cb_test_hs_sfield_select_duration() {      // get option test_hs_options['duration_months'] value from db.     // Set to '5' as default if option does not exist.     $  options  = get_option( 'test_hs_options', [ 'duration_months' => '5' ] );      $  duration = $  options['duration_months']; // fails!      var_dump($  options); // PHP Notice:  Undefined index: duration_months      // define the select option values for 'duration' select field.     $  months = array( '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12' );      // Display select control     echo '<select id="duration" name="test_hs_options[duration_months]">';         // loop through option values         foreach ( $  months as $  month ) {             // if saved option matches the option value, select it.             echo '<option value="' . $  month . '" ' . selected( $  duration, $  month, false ) . '>' . esc_html( $  month ) . '</option>';         }     echo '</select>'; }  

Are your default racial traits suppressed when choosing the Doppelganger Character Secret?

Icewind Dale: Rime of the Frostmaiden contains a Character Secrets section, one of which is "Doppelganger" :

I’m a shapechanger. I have none of the traits of the race I’m imitating, but I retain my class features, background, and alignment. I have darkvision out to a range of 60 feet. I can use an action to do either of the following at will:

I can innately cast detect thoughts, requiring no components. My spellcasting ability is Intelligence. The spell’s Wisdom save DC is 8 + my proficiency bonus + my Intelligence modifier. I can polymorph into any humanoid I have seen or back into my true form. My statistics, other than my size, don’t change. Any equipment I’m wearing or carrying isn’t transformed. I revert to my true form when I die.

Does this mean that your default race’s traits are nullified when selecting this Character Secret ? Example – a Variant Human Doppelganger wouldn’t have the +1 bonus to two ability scores, the extra skill & extra feat, with that interpretation.

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] 

Running PHP echo $_SERVER [‘DOCUMENT_ROOT’]; Shows Apache Default Path

Trying to get set up and running on a new hosting company after the old one announced they are discontinuing their service at the end of the year, I am having difficulty getting the sites to run. I narrowed it down to Apache’s DocumentRoot for each domain showing the Apache default path rather than showing the path to the individual site’s file location. In other words, when I run echo $ _SERVER ['DOCUMENT_ROOT']; in a test script, it shows the path as /etc/apache2/htdocs when it should show /home/username/public_html/domain.com. They seem unable to fix it so can DocumentRoot be changed through cPanel for each domain?

Is it recommended to drop all traffic by default in iptables and then accept only what is required?

I was told using iptables -P OUTPUT DROP and then rules such as iptables -A OUTPUT -p tcp --dport 80 -m state --state NEW -j ACCEPT to accept what is required didn’t do much from a security standpoint. Is that true?

This is what I am been using for some time (planning on implementing some SSH brute force rules shortly):

apt update apt install -y iptables-persistent iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -A OUTPUT -o lo -j ACCEPT iptables -A OUTPUT -p tcp --dport 53 -m state --state NEW -j ACCEPT iptables -A OUTPUT -p udp --dport 53 -m state --state NEW -j ACCEPT iptables -A OUTPUT -p tcp --dport 80 -m state --state NEW -j ACCEPT iptables -A OUTPUT -p tcp --dport 443 -m state --state NEW -j ACCEPT iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -P FORWARD DROP iptables -P INPUT DROP iptables -P OUTPUT DROP iptables-save > /etc/iptables/rules.v4 

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' ); 

Default Game Window Size To Take While Making Games

I am planning to make a game for mobiles and tablets, I wanted to know what would be the default resolution that I should set for my game so that it covers all or most of the devices out there.
I read an article someplace that says we should design the game for lowest resolution like 480 x 360 and then scale it according to devicePixelRatio for the target device, Is this the right approach because according to me it will be good only for devices that have 3:2 resolution but what about other 16:9, 16:10 etc
So What should be the base resolution I design my game so that it gets scaled to all mobiles and tablets
Thanks