Pages

Thursday, October 11, 2012

Wordpress Create Plugin with sortcode

/*Sortcode Display*/
    function Test_Plugin_name($content) {
        if (strpos($content, '[JayMap]') !== FALSE) {
            $qaform = "jaydeep";
            /*
                if you want to replace it with html entites than use below code
                $content = preg_replace('/<p>\s*<!–(.*)–>\s*<\/p>/i', "<!–$1–>", $content);
            */
            $content = str_replace('[JayMap]', $qaform, $content);
        }
        return $content;
    }
    add_filter('the_content', 'Test_Plugin_name');
    add_filter('widget_text', 'Test_Plugin_name');
    /*Sortcode Display*/

Saturday, October 6, 2012

Create Extra Menu in wordpress


Please write below code in "function.php"

// create custom plugin settings menu
add_action('admin_menu', 'social_create_menu');
function social_create_menu() {
    add_menu_page('Theme Settings', 'Theme Settings', 'administrator', __FILE__, 'social_settings_page','../images/social_windows_button.png');
    add_action( 'admin_init', 'register_mysettings' );
}
function register_mysettings() {
    register_setting( 'social-settings-group', 'facebook_link' );
}
function social_settings_page() {    ?>
<div class="wrap"><br>
<fieldset style="border: 1px solid #cccccc; padding: 10px; margin: 10px 0;">
<legend style="font-size:18px;">Social Links</legend>
<form method="post" action="options.php">
    <?php settings_fields( 'social-settings-group' ); ?>
    <table class="form-table">
        <tr valign="top"><td style="width:125px;"><img src="../images/social_facebook.png" style="vertical-align: middle;" title="Facebook" alt="Facebook">&nbsp;Facebook</td><td><input type="text" name="facebook_link" value="<?php echo get_option('facebook_link'); ?>" style="width:300px;"></td></tr>          
    </table>
</fieldset>
 <p class="submit">
    <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
    </p>
</form>
</div>
<?php }

/* Create admin menu Ends */