How to auto run a search plugin, doing a different search every hour?
-
We know that we can launch scripts, files of various extensions through scheduling means, with resources such as wp cron, or directly by the linux cron job, where most of the applications are based to take some action.
Β But I have an old doubt …
Β
Β Β I have a plugin that like most plugins, owns your page in wordpress dashboardΒ Β And in this your page, there are elements necessary to execute the action that the plugin was proposed to do:
Β Β An import plugin, which has on your page, these 3 elements:
Β Β A search bar to promote a search (obviously we must auto fill with the value that refers to the type of content we want to import to each hour),
Β Β A search button.
Β Β An import button.
Β Β Then this page has the name of page.php inside the plugin folder .. how would I do to perform this action in the plugin?
Β I always modify my preferred plugins, leave checked by default, those questions that I’m used to using on all websites, a form for example, I open the plugin zip and search for the words using grep via command line, and always find in the code, those Plugin options that I usually check or uncheck or leave pre-filled fields by default. How much I install the plugin, it already is how I like it π
Β But of course I will not fill the plugin page with a single value, if I want it to fire every hour with a different search, let’s say I want 24 different searches, one for each hour of the day (60 Minutes in cron).
Β Β How is this done? Should we create 24 .php files inside the plugin folder, and call the page.php plugin file and have those fields filled with the different word of each subject that we should fetch in each hour? How does this work?
Β Β Every 60 minutes, a different file will come with a different keyword in the plugin and click search on the import button? Or will the file call the function of the plugin and to auto-fill these fields from our own files.php? I have no idea how this works!
- This topic was modified 7 years, 6 months ago by herculesnetwork.
- This topic was modified 7 years, 6 months ago by herculesnetwork.
- This topic was modified 7 years, 6 months ago by herculesnetwork.
- This topic was modified 7 years, 6 months ago by herculesnetwork.
-
There is no any plugin available for this unique feature and I would suggest to hire a freelancer to make this feature.
Hi Hercules!
It’s been a busy week, I’m just now catching up on topics I haven’t looked at yet.
Perhaps you know WP has its own Cron Job of a sort. It is not related to Linux Cron Jobs at all, it is driven by requests to WP. No requests, nothing happens. With search bots and other spiders crawling about on public sites, this isn’t a big problem, though the event may not run exactly on time. It’ll run after the designated time once someone or something makes a WP request. The main advantage is you don’t need to work out a command line item for CronTab. WP doesn’t normally respond to commands, but the WP-CLI plugin provides a command interface to WP.
The normal search function within WP only searches within the various posts. It sounds like you are searching externally. I’m assuming your plugin manages this somehow. You need to determine how the plugin initiates a search when the search terms are entered manually and the Search button is clicked. Typically it is a form submit to somewhere, with the terms sent along as data by either POST or GET methods. You would need a script that takes search term data from somewhere, a text file perhaps. The script makes a request just as the browser would. There are a number of possibilities for how to do this. WP has a WP_Http class that can make requests. Plain old file_get_contents() might even work. I like using cURL, but it is not available on all servers.
After the request, the results come back in a data stream. The format depends on the app that received the request. Your script would parse it in some way to figure out how to import more of what was found. Once again, the import function would be initiated in a similar manner. Determine how it’s triggered and what data it needs in what format, then cause your script to do that.
Like mdshak suggested, I think this might be more than you can manage. But if you want to make the effort, I’ll try to advise in any way I can. It may not be much.
Hi BCWorkZ! Thaaannks again!
Β Β Β Β Β Yes I want to make the effort, because I mainly want to understand this, since I already have the plugin that does this at the moment just for the task of its own, in the case that I need to learn. Which is how to trigger actions in plugin automatically.Β Β However, if I learn how to do this, I can do this with several other plugins that I have done in the last few months and develop many great ideas about my current project.
Β Β I really want to learn how to trigger actions in third-party plugin .. you do not mind the response time to help me in that case! I have a great need to learn this, but it is not a necessity itself, it is not urgent π Especially in this case is to learn and understand better, with the case to examine the values ββto find out how many numbers are repeated in a sequence set, A task not so necessary, but of extreme curiosity, of very valuable knowledge for me, and which will surely add much in the near future.
Β Well, here’s a screenshot I’ve created to show more or less his method.
Β Β Note that when we do a search, it creates a feed, it adds that search to a list with those searches already made, and the keyword is inserted, and there is a button to activate and deactivate auto import, to repeat every hour that task That we did a single hand manually, make a search and click on import, this is just to understand the method, of course I do not need to create such a menu, nor have any of these sophisticated options, what I want is to be able to write a code In the directories of the plugins, and if necessary, to create a new script for each key word, different search, I do not care, if for 25 categories, 25 searches on my site, I need to create a new script, Do everything manually, for each different search a different script, so that these feeds that I write manually within the directories, can be triggered automatically by some kind of cron like wp cron, without myself having to remember Air of the existence of them srsr, can be all without any sophistication, nothing visual, custom fields, etc … in wordpress dashboard, I just need to make myself able to make scripts run only with their filled fields. I was imagined, to be like that, say that the plugin has a page.php file with that page of the plugin available in our dash wordpress, to make the search the import, I imagined thus, to create page1.php, pege2.php srsrsrr and ja Fill in the field, and sculpt an action to disparage it .. and for the plugin does not give errors for duplicate functions, I’ve been thinking and renaming them with function1 in page1.php function2 in page2.php srsrr for no function error Duplicate different names… So for every hour, I would fire a different page.php, if the plugin has this page, and the import button contained in it, it triggers all the desired action, I imagine that the code should be directed to that page,… I do not know .. I’m trying to guess, srsr
Β Β If you want to take a look at the plugin of the screenshot, I have this plugin, download it here and see if you find it necessary: Download Plugin With this feature His cron folder has a very small file, but I do not understand it!
Β Β Wow how I wish to learn how to trigger actions from various plugins π
THaaankssss. π- This reply was modified 7 years, 6 months ago by herculesnetwork.
- This reply was modified 7 years, 6 months ago by herculesnetwork.
I have been thinking … If it would be better, I create an account on one of these free servers, do a wordpress installation, install a plugin I know well, and we with access to the test server, we would do this in this plugin I know well, Then I would understand how it works, and could adapt to any other plugin code, and later I would explain everything and post here as an answer, this would reduce your time invested in analyzing a plugin for me, which already has that feature up and running, to try Explain to me what was done. And I try to apply in another similar plugin that I know well and that I even want to apply this feature … I think it would be more productive reducing your invested team and easier for me to understand. I’m not in a hurry for this case. I’m just thinking of cutting your time. I’ve solved all the questions in my project for much help from you. Please tell me what you think π Thanks π
Of course you can setup another site if you think it will be helpful, but I’ll tell you right now I probably would not access it. If you find it helpful for yourself, then go ahead. I generally find working on public servers difficult. If need be I can install the plugin on my local development server for analysis.
Don’t be concerned about my time. I spend it as I see fit. It may take some time for me to respond, but I will eventually respond. In the future at some point I may have to say “Sorry, I cannot help you with this.” If that would happen, it’s more likely because I don’t know how to answer than I cannot spend the time.
You should not need to write new code for every different search term. A single form that saves the terms somewhere should be enough. Your script can go through the saved terms to do what it needs to do. For example, you could build your own control panel on a custom page template. The terms could be put into an array, then saved to the page’s post meta. You should have some way of editing and/or removing terms. It can be clunky and awkward if that is easier, as long as there is a way.
To find out how to trigger code from another plugin, use your browser’s network tool to examine where the plugin form goes to do the same thing, as well as what data is being sent. Once you find this out, your script only needs to do the very same thing. It might be helpful to see the code on the receiving end. With direct requests, it shouldn’t be too hard to locate the code. With WP Ajax requests, you need to determine what action parameter was sent.
The action value is used to construct an action tag. Any hyphens are converted to underscores, then the tag becomes
"wp_ajax_{$_POST['action']}"
. Examine the global $wp_filter array for such a tag as a key. The associated value under that key is the name of the callback function. Locate that function in the source code to see what it actually does.All code that is part of the WP installation is part of the same name space. Your script can access any of these as long as they are declared public or not declared as anything, which means they are also public. In short, figure out what the plugin does to initiate something, then cause your code to do the same thing.
Thank you so much my friend for reply… π
Β Β I would not have enough words to say thank you in my language, in English so, I’m missing more words yet … It’s because I’m so grateful to you for so many things, that I’m so embarrassed, I get very shy!
Β Β Let’s go … Well .. I do not sometimes use browser object inspector to see some things from frontend page elements, and field names from some third-party plugins when I want to drop their name attribute, and sometimes I I use linux command line to use the grep tool, to search for and list the files that contain a certain variable, but browser resource, I’m not sure what that would be ?! So it would be during some script execution? !! I’m lost again! I did a great search on the internet about it, and saw some people very interested, but no one got a satisfactory answer, on how to shoot a plugin with the filled fields and perform the action of a click to import, I even found a similar solution, But it was in another plataform cms that did not wordpress, and everything I do is based on wordpress and I love it, and I did not even look right at the article, it seemed all very different! In short, I will put here the code of the page of form of the plugin that I must fill the field of search and the button import action.The Plugin To make Auto import – auto action
This plugin has 3 “important” files where it is in those files that I make all kinds of changes that I needed, Home.php exist small form, 1 text field and 1 search button, after this 2 actions, call page_ajax.php files, and this form 2, we have 2 elements: “see next page” and 1 button “import selected”, (only this 2 files are used by this action that needed to be automatized) and too 2 files not are important to this case: import_ajax.php(this_I_has_did_severals_changes_it_fire_the_import_and_create_Posts_but_this_is_just_to_make-publish_posts) and thebrand-importer.php (less modifications).
Please See you 2 used files by plugin in import action I has explaned plugin event π
Thankkssss again BCWorkZ π
I can tell you more about using your browser’s network activity developer tool if I knew what browser you prefer, but it is probably not necessary for this after all. You should still take a look some time, it’s useful for analyzing where the bottlenecks are when pages are slow to load, as well as seeing what data is being transmitted.
I looked at the page source you posted at pastebin. All those forms are processed by Ajax requests initiated by jQuery script. How are you with writing jQuery code? You don’t need to be that well versed, you have code to copy from π Having some idea what the code does and knowing proper syntax is helpful though. There are 4 different Ajax scripts, one for each different button. They all start out similarly:
jQuery('#button-ID').click( function() { jQuery.ajax({ type: "post", url: "admin-ajax.php", data: { action: 'thebrand_load_*', // more data follows...
The first hashtag string is the ID of the button from which the script is listening for a click event. When clicked, the subsequent anonymous function executes. The function’s first line is jQuery.ajax(), which makes the Ajax request. The .ajax() function is passed an argument array of several values.
In PHP, array syntax is something like
['key1'=>'data1','key2'=>'data2',]
The [square brackets] are a shortcut for array() in recent PHP versions.The same array in JavaScript/jQuery is
{key1: 'data1', key2: 'data2'}
The first array element passed to .ajax() is
type: "post"
. The only other option is GET. For the most part, POST is superior.Next is
url: "admin-ajax.php"
. This is where the request is sent. All WP Ajax requests must go through this file, there are no exceptions. I’ll assume you removed the rest of the url because relative references are not good in WP. A full URL should be used.Finally we have
data: { action: 'thebrand_load_*'
. The data key is assigned an array of data. The first element isaction:
. This is required for all WP ajax requests, the value is used to build an action tag which is hooked to add a callback function which processes the Ajax request server side. This code has variations of ‘thebrand_load_’+ something. Take ‘thebrand_load_keyword’ for example. WP builds an action tag called ‘wp_ajax_thebrand_load_keyword’ for use by logged in users. A different tag is built for not logged in users.In the plugin’s PHP code, there might be something like this:
add_action('wp_ajax_thebrand_load_keyword', 'tb_load_keyword'); function tb_load_keyword() { if ( array_key_exists('rating', $_POST )) { // do something with $_POST['rating'] // more code...
The tb_load_keyword() function is called when admin-ajax.php receives a request where the action: value is ‘thebrand_load_keyword’
That is all mainly background information so you understand what is going on. All you really need to know is you need to make the same sort of Ajax request, passing the data in the same way, except your code will not execute on click, but when a timer function fires, and instead of getting data from a form, you get it from somewhere else not yet determined.
For example, the plugin code does
k: jQuery( '#keyword' ).val()
, which gets the value from the field with an ID of “keyword”. When this value gets to PHP, it is available in $_POST[‘k’]`. You’ll get data from elsewhere, but still assign it to k: so the PHP script still gets the same data that it’s expecting. And so on for the rest of the data.After the data: {…}, code, there are still more array key: data pairs passed to .ajax(). Most important is
success: function( html ){//more code...
. The success: key has a function that executes when the server responds to the Ajax request. In this case it is an anonymous function (often called a “closure”). It could also be the name of a function declared elsewhere. The entire server response is passed to the function ashtml
. This could be as simple as yes or no or 1 or 0, or several pages of data. In this script, besides some animation effects, the function callsjQuery("#formstatus").html( html );
. This places the server response in a element with an ID=”formstatus”.While your Ajax call must also have a success: function(html){}, element in the array, you don’t have to do anything with the returned data.
After all of that, it occurs to me you do not need to do Ajax at all! You still should understand what’s going on with the plugin’s Ajax so you can adapt your code. You are running automation on the server in PHP. There is no browser page to run jQuery from. When you use WP Cron, it is in a way similar to Ajax handlers. When you schedule an event with <a href=”https://codex.wordpress.org/Function_Reference/wp_schedule_event”>wp_schedule_event()</a>, you supply an action tag as the third argument. At the appropriate time, WP fires off this action and any callbacks added to that action hook will execute.
What your WP Cron callback should do is simulate an Ajax request. First, populate $_POST with the proper key/value pairs that would normally be the field values. Then call do_action() using the proper action tag that admin-ajax.php would have built. This will cause the main plugin to process your data as though it came from a form.
The one thing I’m not too sure of is how to capture the server response that would normally be passed to the jQuery.ajax() success: function. This output is normally sent by the server with the usual echo statement. Since there is no browser accepting server output, the output just disappears. You might think an output buffer could be used to capture output. That may be, but there is no way to to get the contents because part of what Ajax handlers do after they are finished is call
exit;
, killing off the thread started by the scheduled event.You may need to hack the plugin Ajax handler to start an output buffer. Just before the exit is called, get the buffer content and save it to a session variable. Then echo the buffer content so any true Ajax request still gets the returned data it was expecting. Then another scheduled event that runs shortly after can get the content in the session variable and do something with it.
You’ll want to do some simple proof of concept experiments to confirm if this scheme will really work before investing a lot of time in development. If this doesn’t work out we are back to running everything from jQuery, which makes it difficult to run full automation since a browser window needs to be kept open.
The final part of this is where to get the data that is fed to the plugin Ajax handlers. I think the best approach is to define a PHP data structure that contains the initial “seed” data. It can then be stored in the DB, maybe in the options table. Store the entire thing under a single option key. Then your script can alter the data as things progress, removing terms already used and adding new terms as they are found.
You will eventually need to locate the Ajax handler functions so you can hack them to use an output buffer. You can get their names from the global $wp_filter array, stored under the key matching the action hook. For example, to find the handler function name for the
action: 'thebrand_load_keyword'
Look at the data under $wp_filter[‘wp_ajax_thebrand_load_keyword’]->callbacks, which will be an array of numeric keys. Under each numeric key is another array where each key is the callback function. There is likely only one key and it is likely under the default 10 numeric key. Somewhat a wild guess, but the function name should thus be the key in the array $wp_filter[‘wp_ajax_thebrand_load_keyword’]->callbacks[10]Well, that should keep you busy for a while π Mainly just becoming familiar with what the plugin’s Ajax is doing so your script can mimic the behavior. Establish what data you need to feed into each Ajax handler and design a useful PHP data structure to contain your terms. Setup a proof of concept test to ensure you can get to the returned data despite the inevitable
exit;
statement. And most importantly, have fun learning πThankssss BCWorkZ Again,
I received your response as soon as you wrote it, I danced here with joy just because you did this complete analysis of the situation, I was thinking if I had shown well about the plugin, I see it was a good presentation of it, π
offtopic:
Β Β As soon as I read your answer, I came across a problem that started when I updated my wordpress for last summer. A plugin that saved me crashed! Was the bulk rename plugin (Rename Featured Image by hirishv90) it saved me, because just this plugin we are dealing with in this topic as an automotive example, it makes postings and creates featured images where my posts receive images with horrible names iudhog64544dfkjfdfdf654646884afakfnf.jpg and are Applied as featured images, which bulk rename plugin I used which is a third part plugin, here from the wordoress repository. He undid this dirt in the names of the images, he put the same post_title, very good for SEO after applying the rules, but it does not work anymore, he does not even appear the action menu anymore! So I stayed from Saturday straight, without stopping in this I’m exhausted! For this I did not expect! I created a topic in the Stack about this, because here we are already dealing with that which is a doubt that I have for years: how to automatic actions in plugins!, and we are doing well talking about it!I think I’m going to open a topic here too, about this, I’d like to do it later, but I’m having a lot of images with unfriendly names for google!
begin;
Yes, even if it is not necessary for this case to learn about analyzing the data during a browser run, I am very interested, yes, you have no idea of ββthe size of my curiosity π I want to learn this π my favorite browser is firefox π but sometimes I use google chrome and chromium
Β I’ve been thinking, let’s make a single file that calls the parts of the plugin that I want to do the action … so I imagined it like this:
$kwords_to_00_hour = 'sports'; $kwords_to_01_hour = 'funny'; $kwords_to_02_hour = 'cars'; $kwords_to_03_hour = 'foods'; $kwords_to_04_hour = 'dance'; ... $kwords_to_24_hour = 'compilations';
A varaivel for each search gave day done every 60min
Then would there be a timer function that would make a carousel with these variables above? And then placing one of them inside a variable that would come in the place of:
<input type=”text” name=”k” value=”$var_with_result_carousel” placeholder=”asian fun” id=”keyword” maxlength=”2048″ size=”30″ />
Thaaankssss.
- This reply was modified 7 years, 6 months ago by bcworkz. Reason: altered nsfw reference
I hope this message finds you well rested after that long weekend ordeal.
Yes! You have the basic idea for feeding data to the search and retrieval plugin. I initially envisioned data from the DB, but a file as source works equally well if the initial data does not change. It’s easy to append data to files if that is something that’s needed. Altering initial data is even possible, but a little trickier. If that’s needed, data in the DB might be easier.
I didn’t imagine you would use the data in carousel fashion, but I can see how that could be useful. If you do that, there ought to be some mechanism so you avoid retrieving the same content that was retrieved the first time around. You could store the source URLs somewhere and search for matches prior to retrieving data. The source data can grow to substantial volume, making searches slower.
One way to mitigate the source URL volume is to hash the URL and only save the hash. Prior to retrieving data, hash the URL and search for a matching hash. URLs should be pre-processed to be sure the hash function input is formatted consistently. Things like trim whitespace, all lower case, remove accents, etc. The process can be destructive, this URL will not be used again. The idea is to remove any possible variations that could cause the hash to not match.
BTW, please be careful with what examples you provide here. No one here cares what you do on your own site, but content in these forums should remain family appropriate. I’m referring to the placeholder value in the example input tag, where I changed it to “fun” π
I’m a long time FireFox user myself. Like you, other browsers are used for various purposes, but FF is my main browser. Pick “Developer” from the menu, then Network (or do Ctrl-shift-I) Click the gear icon for settings. Checkmark the Disable HTTP cache option under advance Settings. Cached data ruins what you are trying to find out regarding performance. The cache is in use again after you close the tool.
Go back to Network tab at far right. Go to the page you want to analyze, or reload if you already have it up. Watch all sorts of good data be recorded! Do something that causes an Ajax request to be sent. The file in the network list should be admin-ajax.php. Click that line and see even more good data! Click the Params tab.
The parameters give you information about what data was sent. Note the value for action:. That is used to construct the action callback tag that is called to cause the proper Ajax handler to execute server side. If you see action: “foo-bar” and you are logged in, the Ajax handler is hooked to “wp_ajax_foo_bar”. Watch out for hyphens in the data. They are converted to underscores by admin-ajax.php.
On the server, place code on a template somewhere to var_dump the global $wp_filters. Search the output for the action tag. Determine the related callback function name like I mentioned in my previous post (in the next to last paragraph). Grep the plugin code for that function name. Once you find the function declaration, you can examine the source code to see what kind of data it is expecting. If you need to hack the plugin to capture output in a buffer, this is the place to do it. Notice there is likely an
exit;
statement at the end of the function. Whatever you do needs to happen before this.Poke around this tool just to get familiar. There’s all sorts of useful data! The header and timing data is useful for improving page speed performance. If any page data comes from a third party site, like Google fonts for example, look how much longer it takes to get that kind of data! Notice how you can filter what data is shown with the second row: HTML, CSS, JS etc. You can also see how very large images drag down the speed. You can clear the data and start over by clicking the trash can at far left.
I’ll have a look at your recent topic in a while. In the mean time, have fun playing with the network tool!
Hi @bcworkz π
Thank you very much againnn, for the class on data analysis emitted in events triggered by a script :-), I did not know this feature in browsers!!
Let’s go to work about our script “auto run a plugin” π
I’ve been thinking, this script is for more stuff than I was imagining! It will serve many things, imagination is the limit.
I’ve been wondering how this script can be useful for many things ..
Β Β If I learn how to automate a process in a plugin, I will be able to automate other processes of that level. If Β Β Β I’m really impolite with this, imagining the possibilities
You think, many things you can automate too π to avoid forgetfulness and increase productivity π
- This reply was modified 7 years, 6 months ago by herculesnetwork.
- This reply was modified 7 years, 6 months ago by herculesnetwork.
- This reply was modified 7 years, 6 months ago by herculesnetwork.
- This reply was modified 7 years, 6 months ago by herculesnetwork.
Whoa! Slow down there! π
Just joking. You will go insane if you keep adding new ideas to your automation project. Imagining new things is great. Write them down to revisit later. But for now you should focus on the task at hand. Get basic functionality working first. You can incorporate new ideas later.
First you need a callback function that does everything required for a single Cron event. When developing and testing, simply call the function directly from a test page or similar template. The function needs to do everything required automatically with no human input. Any criteria or parameters need to be setup in advance. For example, search terms in a file or in the DB. Your function will get this data when it is called and use it to do its tasks.
Only when your function is working flawlessly do you add a recurring scheduled event to cause it to execute automatically on schedule. Schedule events with wp_schedule_event().
You can see there are not many choices for scheduled intervals. You can schedule for intervals longer than any of the allowed intervals by having your function save the timestamp of when it last ran. Then on each interval that’s too frequent, check the difference between now and the last run timestamp. If adequate time has passed, run the task again, otherwise do nothing.
For example, you want a task to be done every 6 hours. Hourly is too frequent, twice daily is not often enough. Add your function to the action that fires hourly. When called, your function gets the last run timestamp and subtracts it from the current timestamp. If it’s less than, say 19800 seconds (5.5 hours) do nothing, and await for the next interval to fire. If it’s been more than 5.5 hours, it’s close enough to be worth running again, since the next interval will not be for another full hour. Next time may be a bit too late. Especially considering these events do not always fire right on time (but never early).
As you can see from the example, setting this all up is an exercise in doing every thing indirectly. You cannot simply call wp_schedule_event(). It needs to be called from code that we can be reasonably assured will only run once. Otherwise you will get many many events scheduled for the same thing. The example uses register_activation_hook() because it’s reasonable to assume plugins generally are activated only once. Themes have a similar hook. It could also be code that only runs when the site admin submits a form containing a password that should be valid in order to schedule the event.
When you schedule an event, you are merely telling WP what action hook to apply when. You need to add your function as a callback to this hook in order for it to actually run. When WP receives any request, it always checks to see if there is an event recently scheduled. If there is, it fires off the related action. Since you function was added to this action, it is called and whatever it does happens.
When scheduling an event from code that only runs once, it’s a good idea to ensure the event had not already been scheduled. This can be done with wp_get_schedule(). Also, just as there ought to be run once code to schedule an event, there needs to be run once code to clear the scheduled events. This would be done when a plugin or theme is deactivated, or when the site admin submits another form just for this purpose. In this case, wp_clear_scheduled_hook() would be called.
PS — nice work adding whitespace in your last post π
I saw your recent email message. Setting the alt attribute for attachments should be done on import. I’m not sure how off hand, but there ought to be a way. You would need to establish what the value would be. For example it could be taken from the title or filename, except that is abusing the intent of the attribute. It’s purpose is for screen readers to be able to tell the user what the image is about. Filenames generally do not help much for this. OTOH, I doubt many unsighted people would have much interest in your sites. Maybe a blind person could visit because they are doing some kind of research??
Once new imports are taken care of this way, a one time script could be run to update all attachments currently lacking the alt attribute values.
Simulating option selection and mouse clicks by script is possible with jQuery. What might be better is to determine where the submitted settings are sent so the settings take affect. You could then make the same sort of submission without interacting with the form at all.
I don’t see how this would relate to an auto-run script server side though. Viewers are part of the client side browser, they are unrelated to server events. However, you can have a jQuery script that executes once the page is loaded, so it falls under the auto-run category, but very different than WP Cron.
Hey friend, I received your short / advised feedback by email, sorry I was not clear, I should have said it was just a mere comment off topic, about a click event, etc … I really was not asking His help by email, was an offtopic comment that does not even need answers, but I was not clear in my bad writing, I could not ask any real email questions, as if I did not actually, and one Since that was not my true intention, nor did I need any feedback on those quests, but I did not write well, sorry π
Talking a bit about the alt creators plugin in all the image files in the library, it works fine, but I’m afraid it will stop working in the future, and it will not take long for that to happen, since cron cron no longer works .. I’m going to open a topic in the future to see if we update the alt ally directly in the database, I imagine that uses an update $wpdb. But this will ask in another topic(because google loves the alt attrib in pictures) π
And thanks for the feedback, I am really now seeing that there is not much relation, the click event with jquery in plugin that require clicks with the auto run by scheduling, because the click event can be done inside the file itself, so there is not much Relationship with our “auto run a plugin”
So I’ve been wondering … where to start our “auto run a script”?
<? function automatic_plugin_trigger(){ //And now what I do of this code life ... I'm lost, where to start :-( if( wp_next_scheduled( 'automatic_plugin_trigger') ){ wp_clear_scheduled_hook( 'automatic_plugin_trigger' ); } } ?>
I understand a little bit about your guidelines in the above responses, but I do not understand what to do within our function, and what do you do about changes to the orginal files of the target plugin?
Cheerss π
- This reply was modified 7 years, 6 months ago by herculesnetwork.
- This reply was modified 7 years, 6 months ago by herculesnetwork.
- This reply was modified 7 years, 6 months ago by herculesnetwork.
- This reply was modified 7 years, 6 months ago by herculesnetwork.
- This reply was modified 7 years, 6 months ago by herculesnetwork.
Well, don’t be sorry, maybe I didn’t give your message the attention it deserved. It appeared to be WP related, so I asked you to come here for that. If there are non-WP questions or something of a sensitive nature you do not want to discuss in a public forum, it is OK to email me. I only ask that you are clear up front, like “I have a non-WordPress question” or “I have a WordPress question that I cannot discuss publicly”. Or even “I’m just reporting my progress, my questions are rhetorical, no response is required.” I’m not good at inferring intent. It’s best to just tell me outright.
I’m sorry if I misunderstood your intent. It’s more likely I did not read carefully enough than that you wrote poorly. You write English remarkably well (I think it has also improved since we first started), but because of your stream of consciousness style, sometimes the phrasing is awkward, which can cause misunderstanding. The phrasing is not wrong or improper, more just unexpected, which reduces comprehension.
You ask a good question. How do I initiate the code that registers a recurring, scheduled event? Many plugin devs that need to set this sort of thing up do so when their plugin is activated, the remove it when deactivated. This not that bad a way to manage your auto-run tasks. The related plugin would need to be for this sole purpose only so it can be activated or deactivated independently of any other features you may have implemented. You could then use the Codex examples that work off of plugin activation and deactivation hooks.
If you have a settings page for some other code you’ve developed, you could add a button that toggles on or off to start or stop the auto-run code. Much like the Subscribe and Favorite buttons in the sidebar of this page. If you don’t have such a page, it could be added to one of the existing settings pages by using the Settings API or one of the actions provided on several of these pages. In that case, just like the buttons on this page, the events resulting from clicking such a button are best handled with Ajax methods.
If you’ve not setup Ajax in WP before, there are a few quirks where it differs from the usual Ajax techniques used on many web pages. It can be a trial to get it working initially. Debugging can be difficult. Once you get it working and understand the process, subsequent attempts will come much easier.
About what to do with the altered plugin files. First of all, before making changes, make a complete backup as distributed (unless you still have the distribution .zip file) and keep it in a safe place in case you need to revert to the original files. Then after completing your alterations, make a backup set of those files and also keep them in a safe place.
If your changes are overwritten by a plugin update, then you can diff (the Linux command) the two versions and decide how to merge the changes into a single, up to date file.
Hey BCWorkz.. π
I’m worried about all this complexity of querying data and checking if they have already been fired or not, and the function does not fire at a certain time because it’s still a little behind schedule, those your explanations about cron, it’s like I’ve read in a Blog, about how these possibilities of not firing execution, make many programmers use cronjob, would not it be simpler code to not use wp cron to schedule these shots? And I use the server schedules via cronjob to set the time of those firing !?
Cheers π
- The topic ‘How to auto run a search plugin, doing a different search every hour?’ is closed to new replies.