-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
214 lines (184 loc) · 9.49 KB
/
functions.php
File metadata and controls
214 lines (184 loc) · 9.49 KB
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
<?php
//error_reporting ( E_ALL );
//ini_set ( "display_errors" , 1 );
$info = WebThemes::newInstance()->loadThemeInfo( 'shopclass' );
define( 'SHOPCLASS_PATH' , __DIR__ );
define( 'TFC_VER' , $info[ 'version' ] );
// Composer dependency loader
require 'includes/vendor/autoload.php';
// theme classes autoloader
require 'includes/autoloader.php';
/**
* New flashmessage function derived from official function just changed styling to support our theme
*
* @param string $section
* @param string $class
* @param string $id
*/
function tfc_show_flash_message( $section = 'pubMessages' , $class = "flashmessage" , $id = "flashmessage" ) {
$messages = Session::newInstance()->_getMessage( $section );
if ( is_array( $messages ) ) {
foreach ( $messages as $message ) {
if ( isset( $message[ 'msg' ] ) && $message[ 'msg' ] != '' ) {
echo '<div id="' . $id . '" class="' . strtolower( $class ) . '-' . $message[ 'type' ] . ' alert alert-dismissible site-alert fade in">';
echo ' <button type="button" class="close" data-dismiss="alert" aria-label="Close">';
echo ' <span aria-hidden="true">×</span>';
echo ' </button>';
echo '<div class="text-center">' . osc_apply_filter( 'flash_message_text' , $message[ 'msg' ] ) . '</div>';
echo '</div>';
} elseif ( $message != '' ) {
echo '<div id="' . $id . '" class="site-alert alert-primary alert alert-dismissible fade in" >';
echo ' <button type="button" class="close" data-dismiss="alert" aria-label="Close">';
echo ' <span aria-hidden="true">×</span>';
echo ' </button>';
echo '<div class="text-center">' . osc_apply_filter( 'flash_message_text' , $message ) . '</div>';
echo '</div>';
}
}
}
Session::newInstance()->_dropMessage( $section );
}
/**
* Function to return Shopclass theme path or require given file
*
* @param string $file
*
* @return mixed
*/
function tfc_path( $file = '' ) {
if ( ! empty( $file ) ) {
osc_current_web_theme_path( $file );
} else {
return SHOPCLASS_PATH . DIRECTORY_SEPARATOR;
}
return true;
}
if ( ! function_exists( 'logo_header' ) ) {
/**
* @return string
*/
function logo_header() {
$html = '<img border="0" alt="' . osc_page_title() . '" src="' . osc_current_web_theme_url( 'images/logo.jpg' ) . '" />';
if ( file_exists( WebThemes::newInstance()->getCurrentThemePath() . "images/logo.jpg" ) ) {
return $html;
} else if ( tfc_getPref( 'default_logo' ) && ( file_exists( WebThemes::newInstance()->getCurrentThemePath() . "images/default-logo.jpg" ) ) ) {
return '<img border="0" alt="' . osc_page_title() . '" src="' . osc_current_web_theme_url( 'images/default-logo.jpg' ) . '" />';
} else {
return osc_page_title();
}
}
}
// functionality loader
require_once 'includes/core-loader.php';
// include theme actions processing file
require_once 'includes/actions.php';
// Core Functions
require_once 'includes/core-functions.php';
// Custom Functions
tfc_path( 'includes/custom-functions.php' );
// Script/Style Loading functions
require_once 'includes/tfcScript.php';
// Voting plugin helper Functions
if ( class_exists( 'ModelVoting' ) ) {
require_once 'includes/voting/tfcvoting.php';
}
//Admin Forms
if ( OC_ADMIN ) {
require_once 'admin/adminForms.php';
}
osc_run_hook( 'shopclass_admin_settings' );
// install update options
if ( ! function_exists( 'shopclass_theme_update' ) ) {
/**
* Run function after theme update
*/
function shopclass_theme_update() {
//theme settings
//tfc_seo_create_table();
tfc_sphinx_create_table();
tfc_favourite_create_table();
tfc_user_avatar_table();
osc_set_preference( 'version' , TFC_VER , 'shopclass_theme' );
osc_reset_preferences();
}
}
if ( ! function_exists( 'shopclass_theme_install' ) ) {
/**
* Run function after theme install
*/
function shopclass_theme_install() {
//theme settings
if ( ! ( osc_get_preference( 'keyword_placeholder' , 'shopclass_theme' ) ) ) {
osc_set_preference( 'keyword_placeholder' , __( 'ie. PHP Programmer' , 'shopclass' ) , 'shopclass_theme' );
}
if ( ! ( osc_get_preference( 'header_logo_text' , 'shopclass_theme' ) ) ) {
osc_set_preference( 'header_logo_text' , 'ShopClass' , 'shopclass_theme' );
}
if ( ! ( osc_get_preference( 'header_logo_icon' , 'shopclass_theme' ) ) ) {
osc_set_preference( 'header_logo_icon' , 'fa-paper-plane' , 'shopclass_theme' );
}
osc_set_preference( 'facebook_fanpage' , 'osclass' , 'shopclass_theme' );
osc_set_preference( 'twitter_username' , 'osclass' , 'shopclass_theme' );
osc_set_preference( 'header_title_h1' , 'Welcome to Shopclass' , 'shopclass_theme' );
osc_set_preference( 'header_title_h3' , 'Post Ads For Mobile, Cars, Jobs, Real Estate, Services....' , 'shopclass_theme' );
osc_set_preference( 'header_search_title_h3' , 'We got you everything, Find Now ...' , 'shopclass_theme' );
osc_set_preference( 'footer_message' , 'We are your Free and most popular classified ad listing site. Become a free member and start listing your classified and Yellow pages ads within minutes. You can manage all ads from your personalized Dashboard.' , 'shopclass_theme' );
osc_set_preference( 'version' , TFC_VER , 'shopclass_theme' );
osc_set_preference( 'enable_caraousel' , true , 'shopclass_theme' );
osc_set_preference( 'enable_static_map' , true , 'shopclass_theme' );
osc_set_preference( 'footer_link' , true , 'shopclass_theme' );
//Sitemap Settings
osc_set_preference( 'sitemap_number' , 1000 , 'shopclass_theme' );
// Seo Options
osc_set_preference( 'enable_seo' , true , 'shopclass_theme' );
//createTables
//tfc_seo_create_table();
tfc_sphinx_create_table();
tfc_favourite_create_table();
tfc_user_avatar_table();
osc_reset_preferences();
}
}
$versionNew = strtr( $info[ 'version' ] , array ( '.' => '' ) );
$versionOld = strtr( osc_get_preference( 'version' , 'shopclass_theme' ) , array ( '.' => '' ) );
if ( ! ( osc_get_preference( 'version' , 'shopclass_theme' ) ) ) {
shopclass_theme_install();
osc_run_hook( 'shopclass_install' );
osc_add_flash_ok_message( __( 'Hey Welcome To Shopclass Theme, Please Checkout Our Dashboard Options' , 'shopclass' ) , 'admin' );
if ( ! file_exists( osc_uploads_path() . 'categorypics' ) ) {
if ( is_writable( osc_uploads_path() ) ) {
shopclass\includes\classes\tfcFilesClass::copyFolder( SHOPCLASS_PATH . '/assets/categorypics' , osc_uploads_path() . 'categorypics' );
} else {
osc_add_flash_warning_message( __( 'Osclass upload directory is not writable. Category images function will not work.' , 'shopclass' ) , 'admin' );
}
}
if ( ! file_exists( osc_uploads_path() . 'shopclass_slider' ) ) {
if ( is_writable( osc_uploads_path() ) ) {
shopclass\includes\classes\tfcFilesClass::copyFolder( SHOPCLASS_PATH . '/assets/images/bk-image' , osc_uploads_path() . 'shopclass_slider' );
} else {
osc_add_flash_warning_message( __( 'Osclass upload directory is not writable. Main Slider will not work properly.' , 'shopclass' ) , 'admin' );
}
}
} elseif ( $versionNew > $versionOld ) {
shopclass_theme_update();
osc_run_hook( 'shopclass_update' );
osc_add_flash_ok_message( __( 'Great You have updated Shopclass to latest version' , 'shopclass' ) , 'admin' );
if ( ! file_exists( osc_uploads_path() . 'categorypics' ) ) {
if ( is_writable( osc_uploads_path() ) ) {
shopclass\includes\classes\tfcFilesClass::copyFolder( SHOPCLASS_PATH . '/assets/categorypics' , osc_uploads_path() . 'categorypics' );
} else {
osc_add_flash_warning_message( __( 'Osclass upload directory is not writable. Category images function will not work.' , 'shopclass' ) , 'admin' );
}
}
if ( ! file_exists( osc_uploads_path() . 'shopclass_slider' ) ) {
if ( is_writable( osc_uploads_path() ) ) {
shopclass\includes\classes\tfcFilesClass::copyFolder( SHOPCLASS_PATH . '/assets/images/bk-image' , osc_uploads_path() . 'shopclass_slider' );
} else {
osc_add_flash_warning_message( __( 'Osclass upload directory is not writable. Main Slider will not work properly.' , 'shopclass' ) , 'admin' );
}
}
}
osc_run_hook( 'shopclass_loaded' );
$tfcSeo = new shopclass\includes\classes\tfcSeo();
osc_add_hook( 'before_html' , $tfcSeo );
unset( $tfcSeo );