WordPress.org

Support

Support » Plugins and Hacks » SpeakUp! Email Petitions » [Plugin: SpeakUp! Email Petitions] php code?

[Plugin: SpeakUp! Email Petitions] php code?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Kreg

    @kreg

    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?

    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…

    Plugin Author Kreg

    @kreg

    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 😉

    Thanks Kreg,
    Will try it out and report back.

    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!

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

    Plugin Author Kreg

    @kreg

    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.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: SpeakUp! Email Petitions] php code?’ is closed to new replies.
Skip to toolbar