root/afridex/plugins/fresh-page/Main.php

Revision 21, 3.4 kB (checked in by admin, 18 years ago)
Line 
1<?php
2/*
3Plugin Name: FreshPost
4Plugin URI: http://freshout.us/goodies
5Description: Turn WordPress into a CMS.
6Author: Freshout
7Version: .13
8Author URI: http://freshout.us/
9*/
10global $wpdb;
11global $post;
12
13
14
15if (is_admin())
16{
17        include_once('RCCWP_Constant.php');
18        include_once('RCCWP_Application.php');
19       
20        register_activation_hook(dirname(__FILE__) . '/Main.php', array('RCCWP_Application', 'Install'));
21
22        if (get_option(RC_CWP_OPTION_KEY) !== false)
23        {
24                include_once('RCCWP_Menu.php');
25
26                //register_deactivation_hook(dirname(__FILE__) . '/Main.php', array('RCCWP_Application', 'Uninstall'));
27
28
29                add_action('admin_menu', array('RCCWP_Post', 'save_files') );
30
31                add_action('admin_menu', array('RCCWP_Menu', 'AttachCustomWritePanelMenuItems'));
32                add_action('admin_menu', array('RCCWP_Menu', 'DetachWpWritePanelMenuItems'));
33
34                include_once('RCCWP_Processor.php');
35                add_action('init', array('RCCWP_Processor', 'Main'));
36                add_action('admin_menu', array('RCCWP_Menu', 'AttachManagementMenuItem'));
37                add_action('admin_menu', array('RCCWP_Menu', 'AttachOptionsMenuItem'));
38                add_filter('posts_where', array('RCCWP_Menu', 'FilterPostsPagesList'));
39                add_action('admin_head', array('RCCWP_Menu', 'HighlightCustomPanel'));
40
41
42                //add_filter('the_posts', array('RCCWP_Menu', 'FilterPostsPagesList'));
43                //add_filter('get_pages', array('RCCWP_Menu', 'FilterPostsPagesList'));
44
45                include_once('RCCWP_Post.php'); 
46                add_action('edit_post', array('RCCWP_Post', 'SetCustomWritePanel'));
47                add_action('save_post', array('RCCWP_Post', 'SetCustomWritePanel'));
48                add_action('publish_post', array('RCCWP_Post', 'SetCustomWritePanel'));
49
50                add_action('edit_post', array('RCCWP_Post', 'SetMetaValue'));
51                add_action('save_post', array('RCCWP_Post', 'SetMetaValue'));
52                add_action('publish_post', array('RCCWP_Post', 'SetMetaValue'));
53
54                add_filter('wp_redirect', array('RCCWP_Processor', 'Redirect'));
55
56                add_action('shutdown', array('RCCWP_Processor', 'FlushAllOutputBuffer')); 
57        }
58}
59
60require_once 'get-custom.php';
61
62function cwp_add_type_identifier(){ 
63        global $wpdb;
64        global $post;
65       
66        if( isset($_GET['custom-write-panel-id']) && !empty($_GET['custom-write-panel-id']))
67        {
68                $getPostID = $wpdb->get_results("SELECT id, type FROM". RC_CWP_TABLE_WRITE_PANELS ." WHERE id='".$_GET['custom-write-panel-id']."'");
69                echo "<input type=\"hidden\" id=\"post_type\" name=\"post_type\" value=\"". $getPostID[0]->type ."\" />";
70
71        }
72        else{
73                if($post->post_type == 'page') { 
74                        echo "<input type=\"hidden\" id=\"post_type\" name=\"post_type\" value=\"page\" />";
75                } else {
76                        echo "<input type=\"hidden\" id=\"post_type\" name=\"post_type\" value=\"post\" />";
77                }
78
79        }
80} 
81
82function cwp_add_pages_identifiers(){
83        global $post;
84        global $wpdb;
85
86        $key = wp_create_nonce('rc-custom-write-panel');
87        $id = "";
88        $result = $wpdb->get_results( " SELECT meta_value
89                                        FROM $wpdb->postmeta
90                                        WHERE post_id = '$post->ID' and meta_key = '_rc_cwp_write_panel_id'", ARRAY_A );
91       
92        if (count($result) > 0)
93                $id = $result[0]['meta_value'];
94        echo 
95<<<EOF
96                <input type="hidden" name="rc-custom-write-panel-verify-key" id="rc-custom-write-panel-verify-key" value="$key" />
97                <input type="hidden" name="rc-cwp-custom-write-panel-id" value="$id" />
98EOF;
99}
100
101add_action('edit_page_form','cwp_add_pages_identifiers');
102add_action('edit_form_advanced','cwp_add_type_identifier');
103?>
Note: See TracBrowser for help on using the browser.