1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
<?php
class Wcap_TS_Faq_Support {
public static $minimum_capability = 'manage_options';
public static $plugin_name = '';
public static $plugin_prefix = '';
public static $plugin_page = '';
public static $plugin_locale = '';
public static $plugin_folder = '';
public static $plugin_url = '';
public static $template_base = '';
public static $plugin_slug = '';
public static $ts_faq = array ();
public static $ts_faq_submenu_slug = '';
public function __construct( $ts_plugin_mame = '', $ts_plugin_prefix = '', $ts_plugin_page = '', $ts_plugin_locale = '', $ts_plugin_folder_name = '', $ts_plugin_slug = '', $ts_faq_array = array(), $faq_submenu_slug = '' ) {
self::$plugin_name = $ts_plugin_mame;
self::$plugin_prefix = $ts_plugin_prefix;
self::$plugin_page = $ts_plugin_page;
self::$plugin_locale = $ts_plugin_locale;
self::$plugin_slug = $ts_plugin_slug;
self::$ts_faq = $ts_faq_array;
self::$ts_faq_submenu_slug = ( '' == $faq_submenu_slug ) ? self::$plugin_slug : $faq_submenu_slug ;
add_action( self::$plugin_prefix . '_add_submenu', array( &$this, 'ts_add_submenu' ) );
add_action( self::$plugin_prefix . '_add_settings_tab', array( &$this, 'ts_add_new_settings_tab' ) );
add_action( self::$plugin_prefix . '_add_tab_content', array( &$this, 'ts_add_tab_content' ) );
add_action ( self::$plugin_prefix . '_add_meta_footer', array( &$this, 'ts_add_meta_footer_text' ), 10, 1 );
add_action( 'admin_menu', array( &$this, 'ts_admin_menus' ) );
add_action( 'admin_head', array( &$this, 'admin_head' ) );
self::$plugin_folder = $ts_plugin_folder_name;
self::$plugin_url = $this->ts_get_plugin_url();
self::$template_base = $this->ts_get_template_path();
}
public static function ts_add_meta_footer_text () {
?>
<tr> <td> <br></td> </tr>
<tr>
<td colspan="2">
You have any queries? Please check our <a href=<?php echo admin_url( 'index.php?page='.self::$plugin_prefix .'_faq_page' ) ; ?> >FAQ</a> page.
</td>
<tr>
<?php
}
public function ts_admin_menus() {
add_dashboard_page(
sprintf( esc_html__( 'Frequently Asked Questions for %s', self::$plugin_locale ), self::$plugin_name ),
esc_html__( 'Frequently Asked Questions for ' . self::$plugin_name, self::$plugin_locale ),
self::$minimum_capability,
self::$plugin_prefix . '_faq_page',
array( $this, 'ts_faq_support_page' )
);
}
public function admin_head() {
remove_submenu_page( 'index.php', self::$plugin_prefix . '_faq_page' );
}
public function ts_add_submenu() {
$page = add_submenu_page( self::$plugin_slug,
'FAQ & Support',
'FAQ & Support',
'manage_woocommerce',
self::$ts_faq_submenu_slug .
'&action=faq_support_page',
array( &$this, 'ts_add_tab_content' )
);
}
public function ts_add_new_settings_tab() {
$faq_support_page = '';
if( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'faq_support_page' ) {
$faq_support_page = "nav-tab-active";
}
$ts_plugins_page_url = self::$plugin_page . "&action=faq_support_page" ;
?>
<a href="<?php echo $ts_plugins_page_url; ?>" class="nav-tab <?php echo $faq_support_page; ?>"> <?php _e( 'FAQ & Support', self::$plugin_locale ); ?> </a>
<?php
}
public function ts_add_tab_content() {
if( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'faq_support_page' ) {
$this->ts_faq_support_page();
}
}
public function ts_faq_support_page() {
ob_start();
wc_get_template( 'faq-page/faq-page.php',
array(
'ts_plugin_name' => self::$plugin_name,
'ts_faq' => self::$ts_faq
),
self::$plugin_folder,
self::$template_base );
echo ob_get_clean();
}
public function ts_get_plugin_url() {
return plugins_url() . '/' . self::$plugin_folder;
}
public function ts_get_template_path() {
return untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/templates/';
}
}