Advertisement
Guest User

functions.php

a guest
May 10th, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.87 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. * Add your own functions here. You can also copy some of the theme functions into this file.
  5. * Wordpress will use those functions instead of the original functions then.
  6. */
  7.  
  8. function admin_style_font() {
  9. wp_enqueue_style('custom_wp_admin_css', get_template_directory_uri().'/admin-fonts.css');
  10. }
  11. add_action('admin_enqueue_scripts', 'admin_style_font');
  12.  
  13. function custom_admin_js() {
  14. echo '"<script type="text/javascript">mk_visual_selector();</script>"';
  15. }
  16. add_action('admin_footer', 'custom_admin_js');
  17.  
  18. add_filter('relevanssi_pre_excerpt_content', 'rlv_trim_divi_shortcodes');
  19.  
  20. function rlv_trim_divi_shortcodes($content) {
  21.  
  22. $content = preg_replace('/\[\/?vc.*?\]/', '', $content);
  23. $content = preg_replace('/\[\/?mk.*?\]/', '', $content);
  24.  
  25.  
  26. return $content;
  27.  
  28. }
  29.  
  30.  
  31. /**
  32. * groups-cmember.php
  33. *
  34. * Copyright (c) 2015 www.itthinx.com
  35. *
  36. * This code is released under the GNU General Public License.
  37. * See COPYRIGHT.txt and LICENSE.txt.
  38. *
  39. * This code is distributed in the hope that it will be useful,
  40. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  41. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  42. * GNU General Public License for more details.
  43. *
  44. * This header and all notices must be kept intact.
  45. *
  46. * @author itthinx
  47. * @since 1.0.0
  48. *
  49. * Plugin Name: Groups CMember
  50. * Plugin URI: https://github.com/itthinx/groups-cmember
  51. * Description: Provides the [groups_cmember] shortcode. Usage: [groups_cmember group="Blue,Red"]Content to show only if user belongs to groups Blue and Red.[/groups_cmember]
  52. * Version: 1.0.0
  53. * Author: itthinx
  54. * Author URI: http://www.itthinx.com
  55. * Donate-Link: http://www.itthinx.com
  56. * License: GPLv3
  57. */
  58. /**
  59. * Provides a conjunctive conditional shortcode.
  60. */
  61. class Groups_CMember {
  62. /**
  63. * Registers the [groups_cmember] shortcode handler.
  64. */
  65. public static function init() {
  66. add_shortcode( 'groups_cmember', array( __CLASS__, 'groups_cmember_shortcode' ) );
  67. }
  68. /**
  69. * Handles the [groups_cmember] shortcode.
  70. *
  71. * @param array $atts
  72. * @param string $content
  73. * @return string
  74. */
  75. public static function groups_cmember_shortcode( $atts, $content = null ) {
  76. $output ='';
  77. if ( class_exists( 'Groups_Group' ) && method_exists( 'Groups_Group', 'read_by_name' ) ) {
  78. $options = shortcode_atts( array( "group" => "" ), $atts );
  79. $show_content = true;
  80. if ( $content !== null ) {
  81. $groups_user = new Groups_User( get_current_user_id() );
  82. $groups = explode( ",", $options['group'] );
  83. foreach ( $groups as $group ) {
  84. $group = trim( $group );
  85. $current_group = Groups_Group::read( $group );
  86. if ( !$current_group ) {
  87. $current_group = Groups_Group::read_by_name( $group );
  88. }
  89. if ( $current_group ) {
  90. if ( !Groups_User_Group::read( $groups_user->user->ID , $current_group->group_id ) ) {
  91. $show_content = false;
  92. break;
  93. }
  94. }
  95. }
  96. if ( $show_content ) {
  97. remove_shortcode( 'groups_cmember' );
  98. $content = do_shortcode( $content );
  99. add_shortcode( 'groups_cmember', array( __CLASS__, 'groups_cmember' ) );
  100. $output = $content;
  101. }
  102. }
  103. }
  104. return $output;
  105. }
  106. }
  107. Groups_CMember::init();
  108.  
  109.  
  110.  
  111. vc_add_param("vc_row", array(
  112. "type" => "textfield",
  113. "group" => "Groups",
  114. "class" => "",
  115. "heading" => "groups_can",
  116. "param_name" => "groups_can",
  117. 'description' => 'The capability attribute is required and is used to indicate one or more capabilities separated by comma.'
  118. ));
  119. vc_add_param("vc_row", array(
  120. "type" => "textfield",
  121. "group" => "Groups",
  122. "class" => "",
  123. "heading" => "groups_can_not",
  124. "param_name" => "groups_can_not",
  125. 'description' => 'The capability attribute is required and is used to indicate one or more capabilities separated by comma.'
  126. ));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement