From 0ad7b3a26019da1206c71799989ee80ef5a68aff Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 11 Mar 2013 19:18:45 -0400 Subject: [PATCH 1/4] Ignore civicrm.settings.php (which appears when checked out to live WP install) --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index e7683df559d8..be845d56d9fe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *~ *.bak +civicrm +civicrm.settings.php From 6522de75b492e5919169bacec33c9a54d1c82f7b Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 11 Mar 2013 19:51:39 -0400 Subject: [PATCH 2/4] CRM-11823 - WP - Use single generator for html-header We had two ways to add scripts to the header (one based on CRM_Core_Resources, one based on actions 'wp_print_scripts' and 'wp_print_styles'). This patch makes everything go through CRM_Core_Resources. --- civicrm.php | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/civicrm.php b/civicrm.php index 634197e21c82..dc05e9cab9c5 100644 --- a/civicrm.php +++ b/civicrm.php @@ -42,6 +42,7 @@ License: AGPL3 */ +define('CIVICRM_UF_HEAD', TRUE); // there is no session handling in WP hence we start it for CiviCRM pages if (!session_id()) { @@ -323,6 +324,17 @@ function civicrm_wp_invoke() { CRM_Core_Invoke::invoke($args); } +function civicrm_wp_head() { + global $civicrm_root; + if (empty($civicrm_root)) { + return; + } + $region = CRM_Core_Region::instance('html-header', FALSE); + if ($region) { + echo $region->render(''); + } +} + function civicrm_wp_scripts() { if (!civicrm_wp_initialize()) { return; @@ -378,6 +390,8 @@ function civicrm_wp_frontend($shortcode = FALSE) { return; } + CRM_Core_Resources::singleton()->addCoreResources(); + // set the frontend part for civicrm code $config = CRM_Core_Config::singleton(); $config->userFrameworkFrontend = TRUE; @@ -599,6 +613,12 @@ function civicrm_wp_main() { add_shortcode('civicrm', 'civicrm_shortcode_handler'); + if (is_admin()) { + add_action('admin_head', 'civicrm_wp_head'); + } else { + add_action('wp_head', 'civicrm_wp_head'); + } + if (!is_admin()) { add_filter('get_header', 'civicrm_wp_shortcode_includes'); } @@ -608,8 +628,9 @@ function civicrm_wp_main() { } if (!is_admin()) { - add_action('wp_print_styles', 'civicrm_wp_styles'); - add_action('wp_print_scripts', 'civicrm_wp_scripts'); + //x CRM_Core_Resources::singleton()->addCoreResources(); + //x add_action('wp_print_styles', 'civicrm_wp_styles'); + //x add_action('wp_print_scripts', 'civicrm_wp_scripts'); add_action('wp_footer', 'civicrm_buffer_end'); @@ -886,8 +907,10 @@ function civicrm_wp_in_civicrm() { function civicrm_wp_shortcode_includes() { global $post; if (preg_match('/\[civicrm/', $post->post_content)) { - add_action('wp_print_styles', 'civicrm_wp_styles'); - add_action('wp_print_scripts', 'civicrm_wp_scripts'); + civicrm_wp_initialize(); + CRM_Core_Resources::singleton()->addCoreResources(); + //x add_action('wp_print_styles', 'civicrm_wp_styles'); + //x add_action('wp_print_scripts', 'civicrm_wp_scripts'); } } From 749f78e3b9d70432155f0f374f412bdea4dfd6c4 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 11 Mar 2013 19:57:18 -0400 Subject: [PATCH 3/4] CRM-11823 - WP - Remove unused civicrm_wp_styles, civicrm_wp_scripts --- civicrm.php | 56 ----------------------------------------------------- 1 file changed, 56 deletions(-) diff --git a/civicrm.php b/civicrm.php index dc05e9cab9c5..bbca890bb84b 100644 --- a/civicrm.php +++ b/civicrm.php @@ -335,56 +335,6 @@ function civicrm_wp_head() { } } -function civicrm_wp_scripts() { - if (!civicrm_wp_initialize()) { - return; - } - $pluginUrl = plugins_url(); - - $files = CRM_Core_Resources::parseTemplate('CRM/common/jquery.files.tpl'); - foreach ($files as $file => $type) { - if ($type == 'js') { - wp_enqueue_script($file, $pluginUrl . "/civicrm/civicrm/$file"); - } - } - - // add localized calendar js - $config = CRM_Core_Config::singleton(); - $localisation = explode('_', $config->lcMessages); - $localizationFile = '/civicrm/civicrm/packages/jquery/jquery-ui-1.9.0/development-bundle/ui/i18n/jquery.ui.datepicker-' . $localisation[0] . '.js'; - - if (file_exists( WP_PLUGIN_DIR . $localizationFile)) { - wp_enqueue_script('civicrm-datepicker', $pluginUrl . $localizationFile); - } - - //add namespacing js - wp_enqueue_script('js/jquery.conflict.js', $pluginUrl . '/civicrm/civicrm/js/jquery.conflict.js'); - - return; -} - -function civicrm_wp_styles() { - if (!civicrm_wp_initialize()) { - return; - } - $pluginUrl = plugins_url(); - - $files = CRM_Core_Resources::parseTemplate('CRM/common/jquery.files.tpl'); - foreach ($files as $file => $type) { - if ($type == 'css') { - wp_register_style($file, $pluginUrl . "/civicrm/civicrm/$file"); - wp_enqueue_style($file); - } - } - - wp_register_style('civicrm/css/civicrm.css', $pluginUrl . "/civicrm/civicrm/css/civicrm.css"); - wp_enqueue_style('civicrm/css/civicrm.css'); - wp_register_style('civicrm/css/extras.css', $pluginUrl . "/civicrm/civicrm/css/extras.css"); - wp_enqueue_style('civicrm/css/extras.css'); - - return; -} - function civicrm_wp_frontend($shortcode = FALSE) { if (!civicrm_wp_initialize()) { return; @@ -628,10 +578,6 @@ function civicrm_wp_main() { } if (!is_admin()) { - //x CRM_Core_Resources::singleton()->addCoreResources(); - //x add_action('wp_print_styles', 'civicrm_wp_styles'); - //x add_action('wp_print_scripts', 'civicrm_wp_scripts'); - add_action('wp_footer', 'civicrm_buffer_end'); // we do this here rather than as an action, since we dont control @@ -909,8 +855,6 @@ function civicrm_wp_shortcode_includes() { if (preg_match('/\[civicrm/', $post->post_content)) { civicrm_wp_initialize(); CRM_Core_Resources::singleton()->addCoreResources(); - //x add_action('wp_print_styles', 'civicrm_wp_styles'); - //x add_action('wp_print_scripts', 'civicrm_wp_scripts'); } } From a67d18d3653335135e4d09eaed5b9b993d8cb796 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 12 Mar 2013 11:23:05 -0400 Subject: [PATCH 4/4] CRM-11823 - WP - Add comment --- civicrm.php | 1 + 1 file changed, 1 insertion(+) diff --git a/civicrm.php b/civicrm.php index bbca890bb84b..247303f88193 100644 --- a/civicrm.php +++ b/civicrm.php @@ -325,6 +325,7 @@ function civicrm_wp_invoke() { } function civicrm_wp_head() { + // CRM-11823 - If Civi bootstrapped, then merge its HTML header with the CMS's header global $civicrm_root; if (empty($civicrm_root)) { return;