Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter Bookkus

    (@bookkus)

    Sorry about the asking for custom work.

    I have this code so far, but it is from an earlier developer. I was wondering how to hook it in.

    <?php
    
    // create custom plugin settings menu
    add_action('admin_menu', 'j_create_menu');
    
    function achievements_tweaks_events_activate() {
    	// add the new 'action' values for achievements into the achievements table.
    	global $wpdb;
    
    	$achievement_category = 'group_review';
    	$achievement_is_group_action = 0;
    	$achievement_name = 'group_review_add_rating';
    	$achievement_description = 'Achieve once group review reached';
    
    	$wpdb->insert( 'wp_achievements_actions', array( 'category' => $achievement_category, 'is_group_action' => $achievement_is_group_action, 'name' => $achievement_name, 'description' => $achievement_description), array( '%s', '%d', '%s', '%s' ) );
    
    }
    
    function achievements_tweaks_events_deactivate() {
    
    	// remove the actions from the table wp_achievements_actions table
    	global $wpdb;
    	$achievement_category = 'group_review'; // make sure this title is unique to your plug-in
    
    	// remove the actions from the table wp_achievements_actions table
    	$wpdb->query("DELETE FROM wp_achievements_actions WHERE category like '".$achievement_category."'");
    
    	// remove any unlocked achievement references to these actions.
    	// we'el leave these hanging in case the achievement is reactivated.
    
    }
    register_deactivation_hook( __FILE__, 'achievements_tweaks_events_deactivate' );
    
    register_activation_hook( __FILE__, 'achievements_tweaks_events_activate' );
    
    function j_create_menu() {
    
    	//create new top-level menu
    	add_menu_page('J Plugin Settings', 'J Settings', 'administrator', __FILE__, 'j_settings_page','');
    
    	//call register settings function
    	add_action( 'admin_init', 'register_mysettings' );
    }
    
    function register_mysettings() {
    	//register our settings
    	register_setting( 'j-settings-group', 'enable_achievement_on_group' );
    /* 	register_setting( 'j-settings-group', 'some_other_option' ); */
    }
    
    function j_settings_page() {
    	?>
    <div class="wrap">
    <h2>J connection options</h2>
    
    <form method="post" action="options.php">
        <?php settings_fields( 'j-settings-group' ); ?>
        <?php //do_settings( 'j-settings-group' ); ?>
        <table class="form-table">
            <tr valign="top">
            <th scope="row">Enable Achievements</th>
            <td><input type="text" name="enable_achievement_on_group" value="<?php echo get_option('enable_achievement_on_group'); ?>" /></td>
            </tr>
    
        </table>
    
        <?php submit_button(); ?>
    
    </form>
    </div>
    <?php }
    
    /**
     * Implements the group_review_add_rating action for BuddyPress
     *
     * @since 2.0
     */
    function dpa_handle_action_group_review_add_rating() { $func_get_args = func_get_args(); dpa_handle_action( 'group_review_add_rating', $func_get_args ); } ?>
Viewing 1 replies (of 1 total)