ansonphong / postworld

Wordpress Theme Development Framework
GNU General Public License v2.0
7 stars 0 forks source link

jsVars Depreciated in favor of pwGlobals #80

Closed ansonphong closed 8 years ago

ansonphong commented 11 years ago

Hi Michel, This is a note to let you know that I am depreciating the $window.jsVars global in favor of a $window.pwGlobals which contains a complex nested set of variables which are being used across many functions.

Since this data is currently being injected directly into the header, which poses some surface level security risks, mainly by making the structure obvious to snoopers, my plan is to bury it under one layer by including a PHP file as a JS document type which defines this, so it's included as an external <script>. Though until that happens, you can find it in the header.

I'll keep jsVars in there for now, although will gradually be refactoring in favor of pwGlobals.

The general anatomy is like this : (still in development)

pwGlobals = {
   "current_view":{
      "type":"post",
      "post":{
         "post_id":200399
      }
   },
   "post_types":{
      "feature":"Features",
      "blog":"Blog",
      "link":"Links",
      "announcement":"Announcements",
      "event":"Events"
   },
   "site_info":{
      "name":"Reality Sandwich",
      "description":"You are what you eat."
   },
   "paths":{
      "home_url":"http:\/\/localhost:8888",
      "wp_url":"http:\/\/localhost:8888",
      "stylesheet_directory":"http:\/\/localhost:8888\/wp-content\/themes\/RSV2",
      "template_url":"http:\/\/localhost:8888\/wp-content\/themes\/RSV2",
      "ajax_url":"http:\/\/localhost:8888\/wp-admin\/admin-ajax.php",
      "plugin_url":"http:\/\/localhost:8888\/wp-content\/plugins"
   },
   "current_user":{
      "data":{
         "ID":"1",
         "user_login":"phong",
         "user_nicename":"phong",
         "user_email":"asun@phong.com",
         "user_url":"",
         "user_registered":"2013-08-16 22:22:22",
         "user_activation_key":"",
         "user_status":"0",
         "display_name":"phong"
      },
      "ID":1,
      "caps":{
         "administrator":"1",
         "membershipadmin":true,
         "membershipadmindashboard":true,
         "membershipadminmembers":true,
         "membershipadminlevels":true,
         "membershipadminsubscriptions":true,
         "membershipadmincoupons":true,
         "membershipadminpurchases":true,
         "membershipadmincommunications":true,
         "membershipadmingroups":true,
         "membershipadminpings":true,
         "membershipadmingateways":true,
         "membershipadminoptions":true,
         "membershipadminupdatepermissions":true
      },
      "cap_key":"wp_capabilities",
      "roles":[
         "administrator"
      ],
      "allcaps":{
         "switch_themes":true,
         "edit_themes":true,
         "activate_plugins":true,
         "edit_plugins":true,
         "edit_users":true,
         "edit_files":true,
         "manage_options":true,
         "moderate_comments":true,
         "manage_categories":true,
         "manage_links":true,
         "upload_files":true,
         "import":true,
         "unfiltered_html":true,
         "edit_posts":true,
         "edit_others_posts":true,
         "edit_published_posts":true,
         "publish_posts":true,
         "edit_pages":true,
         "read":true,
         "level_10":true,
         "level_9":true,
         "level_8":true,
         "level_7":true,
         "level_6":true,
         "level_5":true,
         "level_4":true,
         "level_3":true,
         "level_2":true,
         "level_1":true,
         "level_0":true,
         "edit_others_pages":true,
         "edit_published_pages":true,
         "publish_pages":true,
         "delete_pages":true,
         "delete_others_pages":true,
         "delete_published_pages":true,
         "delete_posts":true,
         "delete_others_posts":true,
         "delete_published_posts":true,
         "delete_private_posts":true,
         "edit_private_posts":true,
         "read_private_posts":true,
         "delete_private_pages":true,
         "edit_private_pages":true,
         "read_private_pages":true,
         "delete_users":true,
         "create_users":true,
         "unfiltered_upload":true,
         "edit_dashboard":true,
         "update_plugins":true,
         "delete_plugins":true,
         "install_plugins":true,
         "update_themes":true,
         "install_themes":true,
         "update_core":true,
         "list_users":true,
         "remove_users":true,
         "add_users":true,
         "promote_users":true,
         "edit_theme_options":true,
         "delete_themes":true,
         "export":true,
         "manage_capabilities":true,
         "pp_manage_settings":true,
         "pp_administer_content":true,
         "pp_create_groups":true,
         "pp_edit_groups":true,
         "pp_delete_groups":true,
         "pp_manage_members":true,
         "pp_assign_roles":true,
         "pp_set_read_exceptions":true,
         "create_posts":true,
         "create_pages":true,
         "edit_others_files":true,
         "publish_files":true,
         "edit_published_files":true,
         "edit_private_files":true,
         "edit_features":true,
         "create_features":true,
         "edit_others_features":true,
         "publish_features":true,
         "edit_published_features":true,
         "edit_private_features":true,
         "edit_blogs":true,
         "create_blogs":true,
         "edit_others_blogs":true,
         "publish_blogs":true,
         "edit_published_blogs":true,
         "edit_private_blogs":true,
         "edit_links":true,
         "create_links":true,
         "edit_others_links":true,
         "publish_links":true,
         "edit_published_links":true,
         "edit_private_links":true,
         "edit_announcements":true,
         "create_announcements":true,
         "edit_others_announcements":true,
         "publish_announcements":true,
         "edit_published_announcements":true,
         "edit_private_announcements":true,
         "edit_events":true,
         "create_events":true,
         "edit_others_events":true,
         "publish_events":true,
         "edit_published_events":true,
         "edit_private_events":true,
         "delete_files":true,
         "delete_others_files":true,
         "delete_published_files":true,
         "delete_private_files":true,
         "delete_features":true,
         "delete_others_features":true,
         "delete_published_features":true,
         "delete_private_features":true,
         "delete_blogs":true,
         "delete_others_blogs":true,
         "delete_published_blogs":true,
         "delete_private_blogs":true,
         "delete_links":true,
         "delete_others_links":true,
         "delete_published_links":true,
         "delete_private_links":true,
         "delete_announcements":true,
         "delete_others_announcements":true,
         "delete_published_announcements":true,
         "delete_private_announcements":true,
         "delete_events":true,
         "delete_others_events":true,
         "delete_published_events":true,
         "delete_private_events":true,
         "read_private_files":true,
         "read_private_features":true,
         "read_private_blogs":true,
         "read_private_links":true,
         "read_private_announcements":true,
         "read_private_events":true,
         "pp_moderate_any":true,
         "administrator":"1",
         "membershipadmin":true,
         "membershipadmindashboard":true,
         "membershipadminmembers":true,
         "membershipadminlevels":true,
         "membershipadminsubscriptions":true,
         "membershipadmincoupons":true,
         "membershipadminpurchases":true,
         "membershipadmincommunications":true,
         "membershipadmingroups":true,
         "membershipadminpings":true,
         "membershipadmingateways":true,
         "membershipadminoptions":true,
         "membershipadminupdatepermissions":true
      },
      "filter":null,
      "postworld":{
         "vote_power":"10"
      },
      "is_admin":false,
      "membership":{
         "is_member":true
      }
   },
   "displayed_user":{
      "user_id":0,
      "display_name":null,
      "first_name":null
   }
};