Jump to content
infogroupsmb

Action Hook For When A Custom Section Is Updated

Recommended Posts

infogroupsmb

I am attempting to write a custom function to send the header and footer areas of the the pages to a .net web service anytime the content of the header or footer area is updated. I have worked out the WordPress action hook for when the menus are updated,

add_action( 'wp_update_nav_menu', 'write_html' );

, but I need to also call my function when the header or footer sections are updated via pagelines. We have custom sections that are being used for the header and footer areas.

I have looked through the Action hooks here: http://api.pagelines.com/hooks

and watched the hook tutorial here: http://www.pagelines.com/docs/base-child-theme

The video is talking more about Filters than Actions (using WordPress terminology) and the list of Actions in the api page doesn't show anything that might relate to updating a specific section.

So I have 2 questions:

1. Is there a pre-exisiting Action hook for when a custom section's site wide settings are updated such as through PageLines > Page Options and selecting the section?

2. If not, how can a custom Action hook be added to a section's update?

Share this post


Link to post
Share on other sites
James B

Hi there, I honestly don't know the answer on that one, but I will forward your request on to one of our developers and either myself or someone on the team will get back to you shortly to advise further.


Kindly search the forum and read the documentation before posting. It will help you resolve many issues.

For CSS help be sure to check out W3Schools first and be sure to download FireBug for FireFox for troubleshooting.

James B

Share this post


Link to post
Share on other sites
Simon

Wordpress has a built in action hook for any option saved to the database, so you can use option_pagelines-settings-two

Share this post


Link to post
Share on other sites
infogroupsmb

If I understand you correctly Simon_P option_pagelines-settings-two will trigger when any option is saved. Is there a way to add an action hook to a specific custom pagelines section? Otherwise option_pagelines-settings-two will be triggering all the time and I only want to do all the processing and call the web service when the menus, custom header section or custom footer section are updated.

Share this post


Link to post
Share on other sites
Simon

Actually thats not gonna work...

This is how id suggest you do it...

First add an action that hooks into the option_pagelines-special option...when its triggered it can copy the settings you are monitoring to a temp setting. The the next time it is triggered, it can compare the saved 'new' setting with your temp setting ( the old one ), if they are different then fire your API calls.

Share this post


Link to post
Share on other sites
infogroupsmb

We don't really care that much if the actual value of the option is being changes, just that someone has updated it. Also, it's not necessary to trigger this when someone makes a page specific change, but only when they update the site default options through pagelines > page options > site defaults.

Share this post


Link to post
Share on other sites
Simon

In that case just use the option_pagelines-special option action

Share this post


Link to post
Share on other sites
infogroupsmb

May I ask for an example? For instance in order to call my updater function when a WP menu is changed I use


add_action( 'wp_update_nav_menu', 'write_html' );

So to trigger the same function when the the page options for the custom header and footer sections are updated I'd use

add_action( 'option_pagelines-special', 'write_html' );

?

And if that is correct, how does it know to only trigger when specific page options are changed, i.e. the header and footer options? I was assuming I'd have to add some custom hook to those 2 sections.

Share this post


Link to post
Share on other sites
infogroupsmb

Ok so


add_action( 'option_pagelines-special', 'write_html' );

seems to trigger any time someone navigates to any page options page, not just when an update occurs.

and

it seems to trigger every time a ploption is pulled to populate the page options page which means it is calls WAY too many times (and has even caused the script to timeout now)

Share this post


Link to post
Share on other sites
infogroupsmb

Simon, though


add_action( 'option_pagelines-special', 'write_html' );

didn't work your suggestion lead me in the right direction. The hook I ended up using is

add_action( 'update_option_pagelines-special', 'write_html' );

Thanks for pointing me in the right direction :D

Share this post


Link to post
Share on other sites
Rob

I'm very happy you were able to resolve this. Well done!


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Similar Content

    • sakkthi subramaniyam
      By sakkthi subramaniyam
      Working on a very old site which has  pagelines framework theme. I need section plugin. so i can install postpins section. I have lost backup copy.
      Thank you.
    • elementalkites
      By elementalkites+
      Good evening. I am attempting to use the Impulse section on a page I am working on (https://dev.elementalkites.com). The tool seems to have the ability to overlay a logo on top of the slider images but in my case it isn't working, even though I have added the logo file and given it a height to display at. I have attached a screenshot for reference. Any help would be appreciated.
       
       
    • jojoking
      By jojoking+
      I have to admit to being baffled.
      I'm trying to embed a video (from my WP media library) within a WP post using the videobox section shortcode.
      The shortcode section popup only allows two items to be configured - the section type, in this case videobox - and a unique id. There's no URL or other parameters such as autoplay or loop which are available within the Pagelines editor.
      Whatever I put in the unique ID makes no difference to what is shown which seems to be a default video with stars or white noise on a black background.
      I assume I need to define this ID somewhere else, or maybe WP has done it for me?
      HELP!
       
      PS This is the page source generated when a shortcode is added within the WP post editor
      <!-- VideoBox | Section --> <section id="videobox_1675853156" class="pl-sn pl-col-sm-12 pl-col-sm-offset-0 pl-sn-videobox" data-object="PL_VideoBox" data-clone="1675853156" data-level="0"><div class="pl-sn-wrap"><div class="pl-sn-pad fix" data-bind="pledit: true" > <div class="video-highlight"><h3 class="video-title" data-bind="pltext: vb_title"></h3></div> <div class="pl-video-box" data-bind="plcallback: { vb_autoplay: vb_autoplay(), vb_loop: vb_loop(), vb_controls: vb_controls(), vb_video: vb_video()}" data-callback="videobox"> <video id="280414138" autoplay loop > <source src="https://www.handinhandmanchester.org.uk/wp-content/plugins/pl-section-videobox/default.mp4?r=280414138" type="video/mp4" /> No browser html5 video. </video> <script> jQuery('#280414138')[0].load(); </script> </div> </div></div></section> </div>  
      If I add a videobox section using the Pagelines page editor the page source generated includes my video:
      <!-- VideoBox | Section --> <section id="videobox_udvu4uz" class="pl-sn pl-col-sm-12 pl-col-sm-offset-0 pl-sn-videobox" data-object="PL_VideoBox" data-clone="udvu4uz" data-level="0"><div class="pl-sn-wrap"><div class="pl-sn-pad fix" data-bind="pledit: true" > <div class="video-highlight"><h3 class="video-title" data-bind="pltext: vb_title"></h3></div> <div class="pl-video-box" data-bind="plcallback: { vb_autoplay: vb_autoplay(), vb_loop: vb_loop(), vb_controls: vb_controls(), vb_video: vb_video()}" data-callback="videobox"> <video id="429558737" autoplay loop > <source src="https://www.handinhandmanchester.org.uk/wp-content/uploads/2017/04/HIHWelcome.mp4?r=429558737" type="video/mp4" /> No browser html5 video. </video> <script> jQuery('#429558737')[0].load(); </script> </div> </div></div></section>  
    • flourishdesignstudio
      By flourishdesignstudio+
      Hi,
      I am having an issue with the Lax sections on Platform 5. I can embed a widget or text box into a Lax section which is really neat, but the image in the background (the parallax image) seems to get stretched and doesn't scale in an attractive way.  For example, the page http://ed6.61e.myftpupload.com/#clients has a parallax section with a woman's face  and I thought is would scale as the browser window gets smaller but the zoom-level never changes. Also, the amount of parallax shift seems more dramatic than what we want. I thought that if I uploaded a shorter image it would scan/scroll less since the height from the image's top to bottom would be less. However, that doesn't seem to have any effect and I am at a loss of how to properly control the way the image is displayed within that box. Any thoughts, tips, or suggestions to get me pointed in the right direction?
      Thanks so much for the help!
    • TourKick (Clifford P)
      By TourKick (Clifford P)
      What's the latest version of DMS2, and is it the last version to ever be expected?
      I ask because v2.2.4 is available but the fix for Google Maps to always load HTTPS instead of HTTP isn't in v2.2.4 -- https://github.com/PageLines-Team/dms/blob/2.2.4/dms/includes/library.pagelines.php#L202 -- but I thought I submitted this pull request in the past (although I can't find it now)
      Also, 
      states v2.2.3 is the latest and not v2.2.4
      Finally, what does this mean:
      ?
       
      Thank you.
×