WordPress.org

Ready to get started?Download WordPress

Forums

SpeakUp! Email Petitions
php code? (8 posts)

  1. yonisink
    Member
    Posted 2 years ago #

    Hi Kregg
    Sweet plugin!
    Quick Q - if we want to include it via PHP in a theme backend, is there anything we can do other than the <? do_shortcode() ?>??

    http://wordpress.org/extend/plugins/speakup-email-petitions/

  2. Kreg Wallace
    Member
    Plugin Author

    Posted 2 years ago #

    Are you wanting to display the petition form in the Admin area? The plugin is designed to only look for the shortcode and load the appropriate JS and CSS files on the public pages of a site. Not sure there's an easy workaround for this. What kind of luck are you having with the do_shortcode() method?

  3. yonisink
    Member
    Posted 2 years ago #

    Kreg,
    No, trying to just include it to load always in a PHP rather than using <? the_content() ?>. Basically as an example, assume we're loading it in a sidebar and just want to do something like <? load_speakup_petition() ?> in sidebar.php. Is that possible? Otherwise I'll try do_shortcode, but usually calling an output function directly is a bit easier...

  4. Kreg Wallace
    Member
    Plugin Author

    Posted 2 years ago #

    There's no way to display the petition form outside of the post loop currently, but I'm hoping to add a widget for the plugin at some point.

    If you wanted to hack at it, doing something like <?php echo dk_speakup_emailpetition_shortcode('1'); ?> would display the form for a petition with the id of '1', but it wouldn't load the CSS or JavaScript necessary for the form to function - and the path back to the AJAX processor wouldn't be available either.

    You could try adding a petition into the content as intended and viewing source to see what CSS and JS get loaded that way and try to rig those into your sidebar somehow to make it functional. No guarantees that this is really possible however ;)

  5. yonisink
    Member
    Posted 2 years ago #

    Thanks Kreg,
    Will try it out and report back.

  6. yonisink
    Member
    Posted 2 years ago #

    Kreg,
    I did something a bit hacky that worked;

    1. I directly called your shortcode function in my file, eg

    <? 	$petition_number = array('id' => '1');
    	dk_speakup_emailpetition_shortcode($petition_number) ?>

    2. To ensure JS/CSS, I changed line 194 to
    $shortcode_found = true;
    bypassing your check for the shortcode.

    I hope you don't mind - you write very elegant code and it would be super-easy to add some function called, say, dk_speakup_output that I could call that would flag a global var called $shortcode_found and allow you to integrate that. Thanks again for your great plugin!

  7. yonisink
    Member
    Posted 2 years ago #

    Whoops, meant to say, in step 2 changed that line in includes/public.php

  8. Kreg Wallace
    Member
    Plugin Author

    Posted 2 years ago #

    Nice work. Glad you got that to work for you. Hopefully I'll be able to get a widget working for the plugin soon to relieve you of the need for the hack.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic