Plugin Directory

Changeset 789136


Ignore:
Timestamp:
10/17/2013 06:48:50 AM (12 years ago)
Author:
apsense
Message:

Added setting link in the plugin.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • qr-code-login-by-tagauth/trunk/tagauth.php

    r789085 r789136  
    55Description: Use mobile to login your wordpress site by scanning QR Code.
    66Version: 1
    7 Author: APSense.com
     7Author: Inhao.com
    88Tags: QR Code Login, inhao, tagbook, scan qr code, login wp by qrcode, apsense
    99Author URI: http://www.inhao.com
    1010*/
    1111
    12 $tagauth_plugin_url = plugins_url() . '/tagauth';
    13 
    14 add_action('admin_menu', 'qr_auth_plugin');
     12$tagauth_plugin_url = plugins_url('' , __FILE__);
    1513add_action('plugins_loaded', 'init_qr_js_list');
     14
     15register_activation_hook( __FILE__, 'qr_auth_pluginInstall' );
    1616register_deactivation_hook( __FILE__, 'qr_auth_pluginUninstall' );
    1717
    18 function qr_auth_pluginUninstall() {
    19     global $wpdb;
    20     $wpdb->query("DROP TABLE IF EXISTS wp_tagauth_settings");
    21     $wpdb->query("DROP TABLE IF EXISTS srv_tagauth_code");
    22     $wpdb->query("DROP TABLE IF EXISTS srv_tagauth_user");
    23     delete_option('tagauth_site_id');
    24     delete_option('tagauth_site_key');
    25 }
    26 
    27 function init_qr_js_list() {
    28     wp_enqueue_script('my_qrcode_js', plugins_url('/qrcode.js', __FILE__));
    29 }
    30 
    31 function qr_auth_plugin() {
     18if ( is_admin() ) {
     19    add_filter('plugin_action_links', 'tagauth_plugin_action_links', 10, 2);
     20    add_action('admin_menu', 'tagauth_admin_menu');
     21}
     22else
     23{
     24    add_action('admin_menu', 'tagauth_user_menu');
     25}
     26
     27function tagauth_admin_menu() {
     28    add_dashboard_page('Get QR Key', 'Get QR Key', 'manage_options', 'get_qr_key', 'get_qr_key');
     29    add_options_page('', 'TagAuth', 'manage_options', __FILE__, 'TagAuth_Settings', '', 6);
     30}
     31
     32function tagauth_user_menu() {
     33    add_dashboard_page('Get QR Key', 'Get QR Key', 'manage_options', 'get_qr_key', 'get_qr_key');
     34}
     35
     36function qr_auth_pluginInstall() {
    3237    global $wpdb;
    3338    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     
    4954          ) ENGINE=MyISAM;";
    5055    dbDelta($sql);
    51     add_dashboard_page('TagAuth Settings', 'TagAuth Settings', 'manage_options', 'TagAuth_Settings', 'TagAuth_Settings');
    52     add_dashboard_page('Get QR Key', 'Get QR Key', 'manage_options', 'get_qr_key', 'get_qr_key');
    53     add_options_page('test1', 'test1', '', 'test1', 'test1');
     56}
     57
     58function qr_auth_pluginUninstall() {
     59    global $wpdb;
     60    $wpdb->query("DROP TABLE IF EXISTS srv_tagauth_code");
     61    $wpdb->query("DROP TABLE IF EXISTS srv_tagauth_user");
     62    delete_option('tagauth_site_id');
     63    delete_option('tagauth_site_key');
     64}
     65
     66function init_qr_js_list() {
     67    wp_enqueue_script('my_qrcode_js', plugins_url('/qrcode.js', __FILE__));
    5468}
    5569
     
    6276<?php
    6377}
    64 
    6578
    6679function TagAuth_Settings() {
     
    132145function get_qr_key() {
    133146
     147    $plugin = plugin_basename(__FILE__);
     148
    134149    $user_id = get_current_user_id();
    135150    global $wpdb;
     
    148163    if ($site_id == 0 || $site_key == '')
    149164    {
    150         echo "<h2>Please setup Site ID and API Key first. <a href='".$_SERVER['REQUEST_URI']."'>Click here to setup</a></h2>";
    151         echo plugin_dir_url( $file );
     165        echo "<h2>Please setup Site ID and API Key first. <a href='options-general.php?page=$plugin'>Click here to setup</a></h2>";
    152166    }
    153167    else
     
    434448    return;
    435449}
    436 ?>
     450
     451function tagauth_plugin_action_links( $links, $file ) {
     452
     453    $plugin = plugin_basename(__FILE__);
     454
     455    // check to make sure we are on the correct plugin
     456    if ( $file == $plugin ) {
     457         $settings_link = "<a href=\"options-general.php?page=$plugin\">" . __('Settings', 'tagauth') . '</a>';
     458        array_unshift( $links, $settings_link );
     459    }
     460 
     461    return $links;
     462}
     463?>
Note: See TracChangeset for help on using the changeset viewer.