Archived
Rename to from society to association
This commit is contained in:
1 parent
e56098c416
commit
e0263e117b
4 files changed
+57
-57
No files matched your search
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Add custom columns. */
|
||||
function neuf_societies_change_columns( $cols ) {
|
||||
function neuf_associations_change_columns( $cols ) {
|
||||
$custom_cols = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Forening', 'trans' ),
|
||||
@@ -12,13 +12,13 @@ function neuf_societies_change_columns( $cols ) {
|
||||
);
|
||||
return $custom_cols;
|
||||
}
|
||||
add_filter( "manage_society_posts_columns", "neuf_societies_change_columns" );
|
||||
add_filter( "manage_association_posts_columns", "neuf_associations_change_columns" );
|
||||
|
||||
// Add values to the custom columns
|
||||
function neuf_societies_custom_columns( $column, $post_id ) {
|
||||
function neuf_associations_custom_columns( $column, $post_id ) {
|
||||
switch ( $column ) {
|
||||
case "homepage":
|
||||
$homepage = get_post_meta( $post_id, '_neuf_societies_homepage', true );
|
||||
$homepage = get_post_meta( $post_id, '_neuf_associations_homepage', true );
|
||||
// default to permalink if not set
|
||||
$homepage = $homepage ? $homepage : get_permalink( $post_id );
|
||||
echo '<a href="'.$homepage.'" alt="'.$homepage.'" target="_blank">'.$homepage.'</a>';
|
||||
@@ -30,10 +30,10 @@ function neuf_societies_custom_columns( $column, $post_id ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
add_action( "manage_posts_custom_column" , "neuf_societies_custom_columns", 10, 2 );
|
||||
add_action( "manage_posts_custom_column" , "neuf_associations_custom_columns", 10, 2 );
|
||||
|
||||
// Make these columns sortable
|
||||
function neuf_societies_sortable_columns( $cols ) {
|
||||
function neuf_associations_sortable_columns( $cols ) {
|
||||
/*$custom_cols = array(
|
||||
'starttime' => 'starttime',
|
||||
'endtime' => 'endtime',
|
||||
@@ -42,30 +42,30 @@ function neuf_societies_sortable_columns( $cols ) {
|
||||
);*/
|
||||
return $cols;
|
||||
}
|
||||
add_filter( "manage_edit-society_sortable_columns", "neuf_societies_sortable_columns" );
|
||||
add_filter( "manage_edit-association_sortable_columns", "neuf_associations_sortable_columns" );
|
||||
|
||||
/* Add metaboxes (with styles) */
|
||||
function add_societies_metaboxes() {
|
||||
function add_associations_metaboxes() {
|
||||
add_meta_box(
|
||||
'neuf_societies_div',
|
||||
'neuf_associations_div',
|
||||
__('Foreningsinformasjon'),
|
||||
'neuf_societies_div',
|
||||
'society',
|
||||
'neuf_associations_div',
|
||||
'association',
|
||||
'side'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/* Metabox with additional info. */
|
||||
function neuf_societies_div(){
|
||||
function neuf_associations_div(){
|
||||
global $post;
|
||||
|
||||
$society_homepage = get_post_meta( $post->ID, '_neuf_societies_homepage', true );
|
||||
$association_homepage = get_post_meta( $post->ID, '_neuf_associations_homepage', true );
|
||||
?>
|
||||
<div class="misc-pub-section misc-pub-section-last">
|
||||
<label for="_neuf_societies_homepage">Hjemmeside:</label>
|
||||
<input type="text" name="_neuf_societies_homepage" value="<?php echo $society_homepage ? $society_homepage : ""; ?>" />
|
||||
<?php wp_nonce_field( 'neuf_societies_nonce', 'neuf_societies_nonce' ); ?>
|
||||
<label for="_neuf_associations_homepage">Hjemmeside:</label>
|
||||
<input type="text" name="_neuf_associations_homepage" value="<?php echo $association_homepage ? $association_homepage : ""; ?>" />
|
||||
<?php wp_nonce_field( 'neuf_associations_nonce', 'neuf_associations_nonce' ); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
@@ -1,26 +1,26 @@
|
||||
<?php
|
||||
/* Setup the custom post type */
|
||||
function neuf_societies_post_type() {
|
||||
function neuf_associations_post_type() {
|
||||
$labels = array(
|
||||
'name' => __( 'Societies' ),
|
||||
'singular_name' => __( 'Society' ),
|
||||
'add_new' => __( 'Add New Society' ),
|
||||
'add_new_item' => __( 'Add New Society' ),
|
||||
'edit_item' => __( 'Edit Society' ),
|
||||
'new_item' => __( 'Add New Society' ),
|
||||
'view_item' => __( 'View Society' ),
|
||||
'search_items' => __( 'Search Societies' ),
|
||||
'not_found' => __( 'No societies found' ),
|
||||
'not_found_in_trash' => __( 'No societies found in trash' )
|
||||
'name' => __( 'Associations' ),
|
||||
'singular_name' => __( 'Association' ),
|
||||
'add_new' => __( 'Add New Association' ),
|
||||
'add_new_item' => __( 'Add New Association' ),
|
||||
'edit_item' => __( 'Edit Association' ),
|
||||
'new_item' => __( 'Add New Association' ),
|
||||
'view_item' => __( 'View Association' ),
|
||||
'search_items' => __( 'Search Associations' ),
|
||||
'not_found' => __( 'No associations found' ),
|
||||
'not_found_in_trash' => __( 'No associations found in trash' )
|
||||
);
|
||||
register_post_type(
|
||||
'society',
|
||||
'association',
|
||||
array(
|
||||
'labels' => $labels,
|
||||
'menu_position' => 5,
|
||||
'public' => true,
|
||||
'publicly_queryable' => true,
|
||||
'query_var' => 'society',
|
||||
'query_var' => 'association',
|
||||
'show_ui' => true,
|
||||
'capability_type' => 'post',
|
||||
'supports' => array(
|
||||
@@ -34,13 +34,13 @@ function neuf_societies_post_type() {
|
||||
'administrator',
|
||||
'custom-fields'
|
||||
),
|
||||
'register_meta_box_cb' => 'add_societies_metaboxes',
|
||||
'register_meta_box_cb' => 'add_associations_metaboxes',
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
/* When the post is saved, saves our custom data */
|
||||
function neuf_societies_save_postdata( $post_id ) {
|
||||
function neuf_associations_save_postdata( $post_id ) {
|
||||
// verify if this is an auto save routine.
|
||||
// If it is our form has not been submitted, so we dont want to do anything
|
||||
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
|
||||
@@ -49,7 +49,7 @@ function neuf_societies_save_postdata( $post_id ) {
|
||||
// verify this came from the our screen and with proper authorization,
|
||||
// because save_post can be triggered at other times
|
||||
|
||||
if ( empty($_POST) || !wp_verify_nonce( $_POST['neuf_societies_nonce'], 'neuf_societies_nonce' ) )
|
||||
if ( empty($_POST) || !wp_verify_nonce( $_POST['neuf_associations_nonce'], 'neuf_associations_nonce' ) )
|
||||
return;
|
||||
|
||||
// Check permissions
|
||||
@@ -66,11 +66,11 @@ function neuf_societies_save_postdata( $post_id ) {
|
||||
// OK, we're authenticated.
|
||||
|
||||
// prefix with protocol if not present
|
||||
$mydata = esc_url( $_POST['_neuf_societies_homepage'] );
|
||||
$mydata = esc_url( $_POST['_neuf_associations_homepage'] );
|
||||
|
||||
// Do something with $mydata
|
||||
// probably using add_post_meta(), update_post_meta(), or
|
||||
// a custom table (see Further Reading section below)
|
||||
update_post_meta($post_id, '_neuf_societies_homepage', $mydata);
|
||||
update_post_meta($post_id, '_neuf_associations_homepage', $mydata);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: neuf-associations
|
||||
Plugin URI: http://www.studentersamfundet.no
|
||||
Description: Association custom post type
|
||||
Version 0.1
|
||||
Author: EDB-web
|
||||
Author URI: http://www.studentersamfundet.no
|
||||
License: GPL v2 or later
|
||||
*/
|
||||
|
||||
/* TODO (nikolark):
|
||||
* - Pickup stuff from: http://codex.wordpress.org/Post_Types
|
||||
*/
|
||||
require_once( 'neuf-associations-post-type.php' );
|
||||
require_once( 'neuf-associations-admin.php' );
|
||||
|
||||
/* Register the post type */
|
||||
add_action( 'init' , 'neuf_associations_post_type' , 0 );
|
||||
add_action( 'save_post' , 'neuf_associations_save_postdata');
|
||||
//add_action( 'publish_post' , 'neuf_associations_save_postdata' );
|
||||
|
||||
?>
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: neuf-societies
|
||||
Plugin URI: http://www.studentersamfundet.no
|
||||
Description: Society custom post type
|
||||
Version 0.1
|
||||
Author: EDB-web
|
||||
Author URI: http://www.studentersamfundet.no
|
||||
License: GPL v2 or later
|
||||
*/
|
||||
|
||||
/* TODO (nikolark):
|
||||
* - Pickup stuff from: http://codex.wordpress.org/Post_Types
|
||||
*/
|
||||
require_once( 'neuf-societies-post-type.php' );
|
||||
require_once( 'neuf-societies-admin.php' );
|
||||
|
||||
/* Register the post type */
|
||||
add_action( 'init' , 'neuf_societies_post_type' , 0 );
|
||||
add_action( 'save_post' , 'neuf_societies_save_postdata');
|
||||
//add_action( 'publish_post' , 'neuf_societies_save_postdata' );
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user