gtm4wp_admin_init

The Google Tag Manager for WordPress gtm4wp admin init function.

Description

gtm4wp_admin_init(); 

Usage

  1. if ( !function_exists( 'gtm4wp_admin_init' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-tag-manager-for-wordpress/admin/admin.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = gtm4wp_admin_init(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/admin/admin.php  
  1. function gtm4wp_admin_init() { 
  2. global $gtm4wp_includefieldtexts, $gtm4wp_eventfieldtexts, $gtm4wp_integratefieldtexts, $gtm4wp_scrollerfieldtexts,  
  3. $gtm4wp_blacklistfieldtexts, $gtm4wp_blacklistmfieldtexts; 
  4.  
  5. register_setting( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS, "gtm4wp_sanitize_options" ); 
  6.  
  7. add_settings_section( 
  8. __( 'General', 'duracelltomi-google-tag-manager' ),  
  9. ); 
  10.  
  11. add_settings_field( 
  12. __( 'Google Tag ManagerID, 'duracelltomi-google-tag-manager' ),  
  13. array( 
  14. "label_for" => GTM4WP_ADMIN_GROUP_GTMID,  
  15. "description" => __( "Enter your Google Tag ManagerIDhere. Use comma without space (, ) to enter multiple IDs.", 'duracelltomi-google-tag-manager' ) 
  16. ); 
  17.  
  18. add_settings_field( 
  19. __( 'Container code placement', 'duracelltomi-google-tag-manager' ),  
  20. array( 
  21. "label_for" => GTM4WP_ADMIN_GROUP_PLACEMENT,  
  22. "description" => __( "Select how your container code should be included in your website.<br />If you select 'Custom' you need to edit your template file and add the following line just after the opening <body> tag:<br /><code><?php if ( function_exists( 'gtm4wp_the_gtm_tag' ) ) { gtm4wp_the_gtm_tag(); } ?></code>", 'duracelltomi-google-tag-manager' ) 
  23. ); 
  24.  
  25. add_settings_section( 
  26. __( 'Basic data', 'duracelltomi-google-tag-manager' ),  
  27. ); 
  28.  
  29. foreach($gtm4wp_includefieldtexts as $fieldid => $fielddata) { 
  30. add_settings_field( 
  31. "gtm4wp-admin-" . $fieldid . "-id",  
  32. $fielddata["label"].'<span class="'.$fielddata["phase"].'"></span>',  
  33. array( 
  34. "label_for" => "gtm4wp-options[" . $fieldid . "]",  
  35. "description" => $fielddata["description"],  
  36. "optionfieldid" => $fieldid 
  37. ); 
  38.  
  39. add_settings_section( 
  40. __( 'Events', 'duracelltomi-google-tag-manager' ),  
  41. ); 
  42.  
  43. foreach($gtm4wp_eventfieldtexts as $fieldid => $fielddata) { 
  44. add_settings_field( 
  45. "gtm4wp-admin-" . $fieldid . "-id",  
  46. $fielddata["label"].'<span class="'.$fielddata["phase"].'"></span>',  
  47. array( 
  48. "label_for" => "gtm4wp-options[" . $fieldid . "]",  
  49. "description" => $fielddata["description"],  
  50. "optionfieldid" => $fieldid 
  51. ); 
  52.  
  53. add_settings_section( 
  54. __( 'Scroll tracking', 'duracelltomi-google-tag-manager' ),  
  55. ); 
  56.  
  57. foreach($gtm4wp_scrollerfieldtexts as $fieldid => $fielddata) { 
  58. add_settings_field( 
  59. "gtm4wp-admin-" . $fieldid . "-id",  
  60. $fielddata["label"].'<span class="'.$fielddata["phase"].'"></span>',  
  61. array( 
  62. "label_for" => "gtm4wp-options[" . $fieldid . "]",  
  63. "description" => $fielddata["description"],  
  64. "optionfieldid" => $fieldid 
  65. ); 
  66.  
  67. add_settings_section( 
  68. __( 'Blacklist tags', 'duracelltomi-google-tag-manager' ),  
  69. ); 
  70.  
  71. foreach($gtm4wp_blacklistfieldtexts as $fieldid => $fielddata) { 
  72. add_settings_field( 
  73. "gtm4wp-admin-" . $fieldid . "-id",  
  74. $fielddata["label"].'<span class="'.$fielddata["phase"].'"></span>',  
  75. array( 
  76. "label_for" => "gtm4wp-options[" . $fieldid . "]",  
  77. "description" => $fielddata["description"],  
  78. "optionfieldid" => $fieldid 
  79. ); 
  80.  
  81. foreach($gtm4wp_blacklistmfieldtexts as $fieldid => $fielddata) { 
  82. add_settings_field( 
  83. "gtm4wp-admin-" . $fieldid . "-id",  
  84. $fielddata["label"].'<span class="'.$fielddata["phase"].'"></span>',  
  85. array( 
  86. "label_for" => "gtm4wp-options[" . $fieldid . "]",  
  87. "description" => $fielddata["description"],  
  88. "optionfieldid" => $fieldid 
  89. ); 
  90.  
  91. add_settings_section( 
  92. __( 'Integration', 'duracelltomi-google-tag-manager' ),  
  93. ); 
  94.  
  95. foreach($gtm4wp_integratefieldtexts as $fieldid => $fielddata) { 
  96. add_settings_field( 
  97. "gtm4wp-admin-" . $fieldid . "-id",  
  98. $fielddata["label"].'<span class="'.$fielddata["phase"].'"></span>',  
  99. array( 
  100. "label_for" => "gtm4wp-options[" . $fieldid . "]",  
  101. "description" => $fielddata["description"],  
  102. "optionfieldid" => $fieldid,  
  103. "plugintocheck" => $fielddata["plugintocheck"] 
  104. ); 
  105.  
  106. add_settings_section( 
  107. __( 'Advanced', 'duracelltomi-google-tag-manager' ),  
  108. ); 
  109.  
  110. add_settings_field( 
  111. __( 'dataLayer variable name', 'duracelltomi-google-tag-manager' ),  
  112. array( 
  113. "label_for" => GTM4WP_ADMIN_GROUP_DATALAYER,  
  114. "description" => __( "In some cases you need to rename the dataLayer variable. You can enter your name here. Leave black for default name: dataLayer", 'duracelltomi-google-tag-manager' ) 
  115. ); 
  116.  
  117. add_settings_section( 
  118. __( 'Credits', 'duracelltomi-google-tag-manager' ),  
  119. ); 
  120.  
  121. add_settings_field( 
  122. __( 'Author', 'duracelltomi-google-tag-manager' ),  
  123. array( 
  124. "label_for" => GTM4WP_ADMIN_GROUP_INFO,  
  125. "description" => '<strong>Thomas Geiger</strong><br /> 
  126. Website: <a href="https://duracelltomi.com/" target="_blank">duracelltomi.com</a><br /> 
  127. <a href="https://www.linkedin.com/in/duracelltomi" target="_blank">Me on LinkedIn</a><br /> 
  128. <a href="http://www.linkedin.com/company/jabjab-online-marketing-ltd-" target="_blank">JabJab Online Marketing on LinkedIn</a>' 
  129. ); 
  130.  
  131. // apply oembed code changes on the admin as well since the oembed call on the admin is cached by WordPress into a transient 
  132. // that is applied on the frontend later 
  133. require_once( dirname( __FILE__ ) . "/../integration/youtube.php" ); 
  134. require_once( dirname( __FILE__ ) . "/../integration/vimeo.php" ); 
  135. require_once( dirname( __FILE__ ) . "/../integration/soundcloud.php" );