| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | Plugin Name: FreshPost |
|---|
| 4 | Plugin URI: http://freshout.us/goodies |
|---|
| 5 | Description: Turn WordPress into a CMS. |
|---|
| 6 | Author: Freshout |
|---|
| 7 | Version: .13 |
|---|
| 8 | Author URI: http://freshout.us/ |
|---|
| 9 | */ |
|---|
| 10 | global $wpdb; |
|---|
| 11 | global $post; |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | if (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 | |
|---|
| 60 | require_once 'get-custom.php'; |
|---|
| 61 | |
|---|
| 62 | function 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 | |
|---|
| 82 | function 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" /> |
|---|
| 98 | EOF; |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | add_action('edit_page_form','cwp_add_pages_identifiers'); |
|---|
| 102 | add_action('edit_form_advanced','cwp_add_type_identifier'); |
|---|
| 103 | ?> |
|---|