Using a custom plugin to capture input data via Ajax and PHP

I’m very new to WordPress, so please excuse my possible lack of understanding. I’m super comfortable with good old vanilla HTML/JS/CSS, and transitioning my hard coded site into WP. My old site had a lot of forms that I used Ajax to send input values over to a PHP script and output a response.

After reading through this site: https://www.smashingmagazine.com/2011/10/how-to-use-ajax-in-wordpress/ I began to understand the basics of how WP likes Ajax requests to be handled. However, the only thing this article left out was how to grab user input data.

So here’s my best explanation of what I’ve tried:

Front End Facing WP Page Code

<input type="text" id="data-to-submit"/>
<?php
  /////////////////////////////////////////////////////////////////////////
  ////PHP code was added to this WP page using PHP-Everwhere plugin //////
  ///////////////////////////////////////////////////////////////////////
  $nonce = wp_create_nonce("my_nonce");
  $link = admin_url('admin-ajax.php?action=my_price_request&nonce='.$nonce);
  echo '<a id="go" data-nonce="'.$nonce.'" href="' . $link . '">Submit</a>';
?>

Then I created a new plugin by going to my cPanel file manager and going to wp-content -> plugins then creating a new folder called myFormProcessor inside this folder I added the following two files:

File #1 myFormProcessor.php

<?php
/*
Plugin Name: myFormProcessor
*/

add_action("init", "my_script_enqueuer");
add_action("wp_ajax_my_price_request", "my_price_request");

function my_price_request(){

  if(!wp_verify_nonce( $_REQUEST('nonce'), "my_nonce")) {
   exit();
}

$result('type') = 'success';
$result('data') = $_REQUEST('data');

if(!empty($_SERVER('HTTP_X_REQUESTED_WITH')) && strtolower($_SERVER('HTTP_X_REQUESTED_WITH')) == 'xmlhttprequest') {
   $result = json_encode($result);
   echo $result;
}else{
  header("Location: ".$_SERVER("HTTP_REFERER"));
}

die();
}

function my_script_enqueuer() {
   wp_register_script( "my_form_script", WP_PLUGIN_URL.'/myFormProcessor/my_form_ajax_script.js', array('jquery') );
   wp_localize_script( 'my_form_script', 'myAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' )));        

   wp_enqueue_script('jquery');
   wp_enqueue_script('my_form_script');
}
?>

I realize the above file doesn’t really do anything. To debug this issue I’m just passing back the value I’m trying to grab from the user.

File #2 my_form_ajax_script.js

jQuery(document).ready( function() {

 jQuery("#go").click( function(e) {
  e.preventDefault(); 
  nonce = jQuery(this).attr("data-nonce");
  data = jQuery('#data-to-submit').val();  // <--- THIS IS THE VALUE I WANT TO PASS TO PHP

  jQuery.ajax({
     type : "post",
     dataType : "json",
     url : myAjax.ajaxurl,
     data : {action: "my_price_request", data : data, nonce: nonce},
     success: function(response) {
        if(response.type == "success") {
           alert(response.data);
        }else{
           alert("error occured");
        }
     },
     error: function (xhr, ajaxOptions, thrownError) {
        console.log(xhr.status);
        console.log(thrownError);
        alert('major error');
     }
  })   
 })
})

I activated the myFormProcessor plugin within WP and tested the page. Good news is most everything worked, no major errors. The only thing that didn’t work was obtaining the value from the input (id=’data-to-submit’). It’s only using the data included in the link produced in the frontend PHP. Can anyone tell me how to correct this?

google sheets – Capture a cell value which updates to a static cell

I have written a straightforward google sheets which dynamically captures closing stock prices in cells in a column for about 30 specific stocks (using their ticker symbol) at the end of the stock market close. At next trading day close these values are overwritten by the new closing prices.

I’d like to preserve these closing prices for some period of time, say a week, such that I can see how a specific stock changes over a week by looking at its closing price over the week. Ideally these stock prices would be written to a new sheet which holds data for a week.

Perhaps a script would accomplish this, but I was thinking that I could do this without a script based on writing a cell value (the one that updates each day) at 4pm ET to a specific cell in a static, non-updating worksheet. The issue is that static cell would need to change by 1 each day. Not sure how to do this without a script and that’s probably beyond my scope.

Was hoping I could do this with GOOGLEFINANCE but I don’t see a way.

Any thoughts?

“Capture full size screenshot” in Brave or Chrome doesn’t work on certain pages (such as Airtable)

I love the “Capture full size screenshot” feature built into Chrome and Brave and use it frequently.

However, it seems that certain websites are coded in a way that the “Capture full size screenshot” feature does not know how to handle. And so then the resulting screenshot does not contain the full scrolled length of the page.

An example I’ve run into multiple times is long forms on https://airtable.com.

I’m wondering if there is some workaround; perhaps I could open the DevTools panel and adjust a certain element’s HTML or CSS before pressing “Capture full size screenshot”. Although it would be annoying to need to do this, I really don’t want to install extensions.

8 – How can I capture a field’s configs and storage so I can delete it and then re-create it?

I’m trying to implement this in a hook_update_N() but I’m not sure it’s proper (see excerpt below). Note I’m changing max_length in the process.

What I’m trying to do: update my_custom_entity.field_my_custom_field which has saved data into it. So I need to:

  1. Store that data
  2. Store the field configs – if that’s possible?
  3. Store the field storage – if that’s possible?
  4. Delete the field
  5. Create the field again using stored configs and storage
  6. Restore the saved data
  // Capture the existing field configs.
  $field = FieldConfig::loadByName($entity_type, $bundle, $field_name);
  $new_field = $field->toArray();
  $new_field('field_type') = 'string';
  $new_field('settings') = ();

  // Capture the existing field storage.
  $new_field_storage = $field_storage->toArray();
  $new_field_storage('type') = 'string';
  $new_field_storage('settings') = (
    'max_length' => $field_length,
    'is_ascii' => FALSE,
    'case_sensitive' => FALSE,
  );

  // Delete existing field + field storage and purge data.
  $field_storage->delete();
  field_purge_batch(150);

  // Create new field using captured configs/settings.
  $new_field_storage = FieldStorageConfig::create($new_field_storage);
  $new_field_storage->save();

  $new_field = FieldConfig::create($new_field);
  $new_field->save();

macos – How to capture global short key on mac to create short key frequency

macos – How to capture global short key on mac to create short key frequency – Ask Different

How to take a screenshot from a video capture?

I recorded a screen capture of catching a shiny Pokemon in Pokemon Go and it about 25 seconds long, with the stars sparkling at about 0:00:11 of the video.

So how do I capture the moment and make it into a photo?


Details: the Play button is there if I pause it, so it is obstructing the video moment if I take a screenshot at the moment. I tried all the options or functions available in the Gallery app and then there seems to be no way.

Capture filter filter with tcpdump/tshark

I’d like to filter ip messages which are constructed as follow:

  1. GRE on top of IP
  2. GRE contains IP with UDP on port 1234

How can I filter such messages?

PS operating system is windows based

cookies – We need to check for and capture a URL parameter that may on any page so we need a efficient way to do this?

We need to track some anonymous users coming to the site with a URL parameter, like “?utc=1234”. This could be on any page though so I don’t know what the most resource-efficient way to accomplish this is.

We are also using Cloudflare and Memcached so I don’t know how this may affect anonymous users.

The use case is, upon a page load, to check if the URL parameter exists and, if it does, then save it to a cookie for later retrieval.

How can I accurately capture the fun and challenge of computer hacking in a LARP?

Make it into a game of Solitaire, with some changes

FYI, I have no experience with LARPing, and haven’t utilized a system like this in real life. I do have some experience with designing simple games.

Make sure each ref has a deck of cards, and each challenge a game of solitaire with a specific requirement needed to make. To speed things up, add random elements like stating that, for this round, suits don’t matter, or the value of a face card is interchangeable with any other face card. Harder challenges require all the cards to be used (like a normal game of Solitaire), where easier challenges only require a single stack to be completed.

For when a hacker is having difficulty, always have the “brute force” timer available, when their “backup system” gets past the issues and the hack succeeds anyway, but this should always be longer than ideal. Base these as being slightly longer than what the existing system uses for a timer. So if it takes one of your current challenges 5 minutes of hacking, the solitaire system should be about 7 minutes for the brute force method.

If you need to balance it out, have two specific timers ready, one for the maximum time it should take for the challenge to complete (the brute force option), and one to prevent too early of access because of a lack of balancing the system (which is 5 minutes earlier than the brute force option).

Meaning that player decision making can only change things within a 5 minute time range. If they beat it too early, they won’t break the event because they’re super smart, and will have to wait for the minimal timer (say it’s a catch up timer as their system is catching up to their fast programming). If they’re too slow, the brute force system will solve it for them.

If they succeed before the brute force timer, they get to memorize one of the system’s “loopholes” (the random rules used to modify the game) and can use it on a future hacking challenge.

Only one loophole can be saved this way, and each loophole can only be used once. After it is used, and the player succeeds on the new challenge, they may not keep the loophole they just used.

To add to the ominous feel and the tension, write the special rules on individual note cards. When a player encounters a hacking challenge, the ref simply hands the player the deck of cards and the note cards of special rules relevant to this challenge.


I suggested this as it does follow some trends of working a computer system in real life.

  • You can teach yourself all of the basics and practice, practice,
    practice, but you will always find things that surprise you.

  • Its strength and difficulty isn’t always reliant on outside sources
    but usually dependent on you, which is why I chose Solitaire as the
    tool of choice.

  • It isn’t always about being the best or most thorough, it’s often
    about finding the one abstract way that makes you succeed, and this
    version of Solitaire provides this via the abstract rulings.

  • Last, but not least, you often find trends in systems that are
    noticeable in similar systems, and you may base a solution from one
    event from something you found in another, and the concept of
    “remembering” a loophole in my example utilizes this kind of idea.

Burp – How to capture local traffic from Android device (i.e traffic that doesn’t use the internet)

I’m trying to intercept traffic between an Andriod App and a Router interface. I’m using a rooted device.

They communicate on port 6699 which I believe is typical for nginx.

I’ve tried setting up Burp to capture the traffic but all it sees is the data the App sends/receives remotely (API calls to the cloud) and nothing it sends/receives locally (API calls to nginx on the router).

It seems like the Burp listener port is only capturing traffic from ports 80 and 443 on the Android device.

How can I set up burp to capture traffic from port 6699?

DreamProxies - Cheapest USA Elite Private Proxies 100 Cheap USA Private Proxies Buy 200 Cheap USA Private Proxies 400 Best Private Proxies Cheap 1000 USA Private Proxies 2000 USA Private Proxies 5000 Cheap USA Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive.com Proxies-free.com New Proxy Lists Every Day Proxies123.com Best Quality USA Private Proxies