WordPress.org

Ready to get started?Download WordPress

Forums

No Adsense Button with Adsense Plugins (1 post)

  1. trivum
    Member
    Posted 7 years ago #

    I am having a problem with all the adsense plugins that I try to install. I have used the one by Phil Hord in the past, and that worked perfectly for me. And, in fact, I don't feel I need any of the features the newer ones have, however with all of the ones I've tried, the newer versions of WordPress don't show the quicktag button in order to automatically insert the <!--adsense--> code.

    I have installed the old Phil Hord plugin and manually inserted <!--adsense--> into my post, and it works fine, and so I would be happy to use it, but I would like to have a quicktag button for it if possible.

    In the plugin itself I have found the following where he talks about adding a button. Would anyone know how to change this so that it would work with the latest versions of WP?

    Thanks for any help. Code below:

    //---- The following AddAButton code comes from the Edit Button Template
    //---- found here: http://codex.wordpress.org/Plugins
    //---- and originally written by Owen Winkler
    //---- It was originally here: http://www.asymptomatic.net/wp-hacks
    //---- But I had trouble downloading it from there.

    add_filter('admin_footer', 'phord_InsertAdsenseButton');

    function phord_InsertAdsenseButton()
    {
    if(strpos($_SERVER['REQUEST_URI'], 'post.php'))
    {
    ?>
    <script language="JavaScript" type="text/javascript"><!--
    var toolbar = document.getElementById("ed_toolbar");
    <?php

    edit_insert_button("Adsense", "adsense_button", "Adsense");

    ?>

    function adsense_button()
    {
    edInsertContent(edCanvas, '<!-'+'-adsense-'+'->');
    }

    //--></script>
    <?php
    }
    }

    if(!function_exists('edit_insert_button'))
    {
    //edit_insert_button: Inserts a button into the editor
    function edit_insert_button($caption, $js_onclick, $title = '')
    {
    ?>
    if(toolbar)
    {
    var theButton = document.createElement('input');
    theButton.type = 'button';
    theButton.value = '<?php echo $caption; ?>';
    theButton.onclick = <?php echo $js_onclick; ?>;
    theButton.className = 'ed_button';
    theButton.title = "<?php echo $title; ?>";
    theButton.id = "<?php echo "ed_{$caption}"; ?>";
    toolbar.appendChild(theButton);
    }
    <?php

    }
    }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic