package = $mega_package;
add_action( 'admin_menu', array( &$this, 'addPage' ));
//add_action( 'after_switch_theme', array( &$this, 'redirect_page' ));
add_action( 'customize_register', array( &$this, 'customize' ));
add_action( 'customize_controls_enqueue_scripts', array( &$this, 'customize_enqueue' ));
add_action( 'customize_preview_init', array( &$this, 'customize_live' ));
}
public function redirect_page()
{
wp_redirect( admin_url( 'themes.php?page=mega' ));
}
public function addPage()
{
global $mega_package;
$this->package = $mega_package;
$title = $this->package === '0' ? esc_html__( 'Upgrade This Theme', 'mega' ) : sprintf( esc_html__( '%s Options', 'mega' ), wp_get_theme()->get( 'Name' ));
$this->page_hook = add_theme_page(
$title,
$title,
'edit_theme_options',
'mega',
array( &$this, 'doPage' )
);
add_action( 'admin_enqueue_scripts', array( &$this, 'enqueue' ));
}
public function doPage()
{
global $mega_s, $mega_logs, $mega_auth;
$n = new Mega_Form_Manager( array( 'type' => 'tabs' ));
if ( $this->package !== '1.1' )
$n->panels['tab-1'] = array( 'title' => esc_html__( 'Home', 'mega' ), 'href' => '#tab-1', 'callback' => array( $this, 'getPackage' ));
if ( $this->package === '0' )
$n->panels['tab-5'] = array( 'title' => esc_html__( 'Authenticate', 'mega' ), 'href' => '#tab-5', 'callback' => array( $mega_auth, 'form' ));
if ( $this->package === '0' )
$n->panels['customize'] = array( 'title' => esc_html__( 'Customize', 'mega' ), 'href' => admin_url( 'customize.php' ));
else
$this->customize( $n );
echo
'
',
'
',
'';
echo '
';
if ( $this->package !== '0' )
$mega_s->page( $n );
else
$n->buildContent( 'tab-1' );
if ( $this->package === '0' )
{
$n->buildContent( 'tab-5' );
}
echo
'
';
//if ( $this->package !== '0' )
$mega_logs->showLogs();
echo
'',
'
',
'
';
}
public function customize( $wp_customize )
{
global $mega_registered_blocks;
$wp_customize->add_panel( 'mega_default_widget_settings', array(
'priority' => 31,
'capability' => 'edit_theme_options',
'theme_supports' => '',
'title' => esc_html__( 'Widget Default', 'mega' ),
'description' => esc_html__( 'This section allows you to specify default settings for the widgets that this theme supports. Upon saving, any new widgets that you\'ll use will have the new settings in place. This doesn\'t affect current widgets that are in use.', 'mega' )
));
if ( $this->package === '0' )
$wp_customize->add_panel( 'mega_default_widget_settings_2', array(
'priority' => 31,
'capability' => 'edit_theme_options',
'theme_supports' => '',
'title' => esc_html__( 'Static Blocks Default', 'mega' ),
'description' => esc_html__( 'This section allows you to specify default settings for static blocks that this theme supports and are shown across the site. Upon theme upgrade, these blocks turn into widgets and are available for drag and drop.', 'mega' )
));
foreach( $mega_registered_blocks as $block )
{
if ( $block->mega['args']['universal'] )
$wp_customize->add_section( $block->mega['args']['id_base_low'] . '_section', array(
'title' => $block->mega['args']['profile']['name'],
'priority' => 31,
'panel' => 'mega_default_widget_settings'
));
else if ( $block->mega['args']['universal_pro'] && $this->package === '0' )
$wp_customize->add_section( $block->mega['args']['id_base_low'] . '_section', array(
'title' => $block->mega['args']['profile']['name'],
'priority' => 31,
'panel' => 'mega_default_widget_settings_2'
));
if ( is_a( $wp_customize, 'Mega_Form_Manager' ))
{
$wp_customize->callback = array( $block, 'setSettings' );
$block->registerSettings( $wp_customize );
}
else
{
$wp_customize->callback = array( $block );
$block->registerSettings( new Mega_Form_Manager( array( 'wp_customize' => $wp_customize )));
}
}
if ( $this->package === '1.1' && is_a( $wp_customize, 'Mega_Form_Manager' ))
$wp_customize->panels['tab-1'] = array( 'title' => esc_html__( 'Get Support', 'mega' ), 'href' => '#tab-1', 'callback' => array( $this, 'getPackage' ));
}
public function getPackage()
{
echo '';
$upgrade_url = mega_upgrade_url( 'body' );
switch( $this->package )
{
case '0' :
echo '
';
echo '
' . sprintf( esc_html__( 'Upgrade this theme today for just %s and get access to extra features.', 'mega' ), '' . mega_remote_data( 'price' ) . '' ) . '';
echo '
';
echo '
';
echo '
';
echo '
' . wp_kses( __( 'Act now, don\'t miss your chance!', 'mega' ), array( 'strong' => true )) . '
';
echo '' . esc_html__( 'don\'t wait too long or the offer might end soon...', 'mega' ) . '';
echo '';
echo '
' . esc_html__( 'Upgrade', 'mega' ) . '';
echo '
';
break;
case '1' :
echo '
' . esc_html__( 'Thank you for upgrading.', 'mega' ) . '
' . wp_kses( __( 'Thank you for upgrading, you are now running the full loaded &
professional version and you have full access to our support.', 'mega' ), array( 'strong' => true ));
break;
case '1.1' :
echo '
' . esc_html__( 'Dear ThemeForest users,', 'mega' ) . '
' . sprintf( esc_html__( 'Thank you for trying this amazing theme powered by MegaThemes, please sign up at %s to get support.', 'mega' ), '
megathemes.com' );
}
echo '
';
}
public function customize_enqueue()
{
wp_localize_script( 'jquery', 'mega_package', array(
'id' => $this->package,
'label' => esc_html__( 'Upgrade this theme.', 'mega' ),
'link' => mega_upgrade_url( 'header' )
));
wp_enqueue_script( 'mega.jquery.lock', MEGA_DIR_URI . '/assets/js/mega.jquery.lock.js', array(), false, true );
wp_enqueue_script( 'mega.jquery.customizer', MEGA_DIR_URI . '/assets/admin/customizer.js', array( 'jquery' ), false, true );
}
public function customize_live()
{
wp_enqueue_script(
'mega-live-customizer',
MEGA_DIR_URI . '/assets/admin/customizer-live.js',
array( 'jquery', 'customize-preview' ),
'',
true
);
}
public function enqueue( $page )
{
global $mega_admin;
if ( $mega_admin->page_hook != $page )
{
if ( $page === 'widgets.php' OR $page === 'customize.php' )
{
wp_localize_script( 'jquery', 'mega_package', array(
'id' => $this->package,
'label' => esc_html__( 'Upgrade this theme.', 'mega' ),
'link' => mega_upgrade_url( 'header' )
));
wp_enqueue_script( 'mega.jquery.lock', MEGA_DIR_URI . '/assets/js/mega.jquery.lock.js', array(), false, true );
wp_enqueue_script( 'mega.jquery.customizer', MEGA_DIR_URI . '/assets/admin/customizer.js', array( 'jquery' ), false, true );
wp_enqueue_style( 'fontawesome' );
wp_enqueue_style( 'ionicons' );
wp_enqueue_style( 'mega.admin.style', MEGA_DIR_URI . '/assets/admin/style-widgets.css' );
wp_enqueue_script( 'mega.jquery.control.checklist' );
}
return false;
}
//if ( $this->page_hook != $this->sub_page() )
//return false;
wp_enqueue_script( 'jquery-ui-tabs' );
wp_enqueue_script( 'swfobject' );
wp_enqueue_script( 'bootstrap.tooltip.min' );
wp_enqueue_style( 'bootstrap.tooltip.min' );
wp_enqueue_script( 'mega.admin.scripts', MEGA_DIR_URI . '/assets/admin/scripts.js' );
wp_enqueue_style( 'fontawesome' );
wp_enqueue_style( 'ionicons' );
wp_enqueue_style( 'mega.admin.style', MEGA_DIR_URI . '/assets/admin/style.css' );
add_filter( 'admin_body_class', array( 'Mega', 'addBodyClass' ));
wp_localize_script( 'jquery', 'mega_package', array( 'id' => $this->package ));
}
}