Skip to content

Commit ab97594

Browse files
Create basic structure for astra child theme.
1 parent b66ffaa commit ab97594

11 files changed

+349
-1
lines changed

assets/js/custom.js

Whitespace-only changes.

includes/admin-settings.php

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?php
2+
/**
3+
*
4+
* @class Wpgenius_settings
5+
* @author Team WPGenius (Makarand Mane)
6+
* @category Admin
7+
* @package wpg-setting-api/includes
8+
* @version 1.0
9+
*/
10+
11+
if ( ! defined( 'ABSPATH' ) ) {
12+
exit;
13+
}
14+
15+
class Wpgenius_settings {
16+
17+
public static $instance;
18+
private $prefix = 'wpg_';
19+
private $opt_grp = 'wpg_api_';
20+
private $page = 'wpg_settings';
21+
22+
public static function init(){
23+
24+
if ( is_null( self::$instance ) )
25+
self::$instance = new Wpgenius_settings();
26+
return self::$instance;
27+
}
28+
29+
private function __construct(){
30+
31+
add_action( 'admin_menu', array($this,'wpg_settings_menu'), 11);
32+
add_action( 'admin_init', array($this,'wpg_register_settings'),10);
33+
34+
} // END public function __construct
35+
36+
function wpg_settings_menu(){
37+
38+
add_submenu_page(
39+
'edit.php?post_type=album',
40+
__('WPGenius Settings' ), // page title
41+
__('Settings' ), // menu title
42+
'manage_options', // capability
43+
$this->page, // menu slug
44+
array( $this, 'wpg_settings_callback')
45+
);
46+
}
47+
48+
function wpg_register_settings() {
49+
50+
//Register settings
51+
register_setting( $this->opt_grp, $this->prefix.'register_setting', array( 'type' => 'string', 'default' => '' ) );
52+
53+
//Register sections
54+
add_settings_section( $this->prefix.'register_section', __('Youtube API','astra-child-theme'), array( $this, 'wpg_register_section_title' ), $this->page );
55+
56+
//Add settings to section- braincert_api_section
57+
add_settings_field( $this->prefix.'register_setting', __('Register setting :','astra-child-theme'), array( $this, 'wpg_register_setting_field' ), $this->page, $this->prefix.'api_section' );
58+
59+
}
60+
61+
function wpg_settings_callback(){
62+
?>
63+
<div class="wrap">
64+
65+
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
66+
67+
<form method="POST" action="options.php">
68+
<?php
69+
// output security fields for the registered setting "wporg"
70+
settings_fields( $this->opt_grp );
71+
// output setting sections and their fields
72+
// (sections are registered for "wporg", each field is registered to a specific section)
73+
do_settings_sections( $this->page );
74+
// output save settings button
75+
submit_button( __( 'Save Settings','astra-child-theme') );
76+
?>
77+
</form>
78+
</div>
79+
<?php
80+
81+
}
82+
83+
function wpg_api_section_title(){
84+
?>
85+
<p><?php _e( 'Get API details from https://developers.google.com/ & put below.','astra-child-theme'); ?></p>
86+
<?php
87+
}
88+
89+
function wpg_register_setting_field(){
90+
?>
91+
<input type='text' name='<?php echo $this->prefix ?>register_setting' id='<?php echo $this->prefix ?>register_setting' value='<?php echo get_option( $this->prefix.'register_setting' );?>' style="width: 300px;">
92+
<?php
93+
}
94+
95+
}
96+
Wpgenius_settings::init();

includes/elementor-widgets.php

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* Create an elementor widget.
4+
*
5+
* @link https://developer.wordpress.org/themes/basics/theme-functions/
6+
*
7+
* @package astra-child-theme
8+
*/
9+
10+
//https://develowp.com/build-a-custom-elementor-widget/
11+
12+
class Wpgenius_Elementor_Widgets {
13+
14+
protected static $instance = null;
15+
16+
public static function get_instance() {
17+
if ( ! isset( static::$instance ) ) {
18+
static::$instance = new static;
19+
}
20+
21+
return static::$instance;
22+
}
23+
24+
protected function __construct() {
25+
// Register widget Styles
26+
add_action( 'elementor/frontend/before_enqueue_styles', [ $this, 'widget_styles' ] );
27+
// Register widget scripts
28+
add_action( 'elementor/frontend/after_register_scripts', [ $this, 'widget_scripts' ] );
29+
// Register widgets
30+
add_action( 'elementor/widgets/widgets_registered', [ $this, 'register_widgets' ] );
31+
}
32+
public function widget_styles() {
33+
34+
//Enqueue styles for widget
35+
36+
}
37+
38+
public function widget_scripts() {
39+
40+
//Enqueue Scripts for widget
41+
42+
}
43+
44+
public function register_widgets() {
45+
//register widget here
46+
require_once( __DIR__.'/widgets/wpg-widget.php');
47+
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Elementor\WPG_widget() );
48+
}
49+
50+
}
51+
52+
function wpg_elementor_widgets() {
53+
Wpgenius_Elementor_Widgets::get_instance();
54+
}
55+
add_action( 'init', 'wpg_elementor_widgets' );

includes/post-type/post-type.php

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
3+
/**
4+
* Create Testimonial post type.
5+
*
6+
* To add custom fields use ACF plugin.
7+
* field names: rating;
8+
*/
9+
function ast_testimonial_post_type()
10+
{
11+
12+
$labels = array(
13+
'name' => __( 'Testimonial', 'astra-child-theme' ),
14+
'singular_name' => __( 'Testimonial', 'astra-child-theme' ),
15+
'all_items' => __( 'All testimonials', 'astra-child-theme' ),
16+
'add_new' => __( 'Add New', 'astra-child-theme' ),
17+
'add_new_item' => __( 'Add new testimonial', 'astra-child-theme' ),
18+
'edit_item' => __( 'Edit testimonial', 'astra-child-theme' ),
19+
'new_item' => __( 'New testimonial', 'astra-child-theme' ),
20+
'view_item' => __( 'View testimonial', 'astra-child-theme' ),
21+
'search_items' => __( 'Search testimonial', 'astra-child-theme' ),
22+
'not_found' => __( 'No testimonial found', 'astra-child-theme' ),
23+
'not_found_in_trash' => __( 'No testimonial found in Trash', 'astra-child-theme' ),
24+
'featured_image' => __( 'Testimonial Cover Photo','astra-child-theme' ),
25+
'set_featured_image' => __('Set as testimonial\'s Cover picture','astra-child-theme'),
26+
);
27+
28+
$args = array(
29+
'numberposts' => 15,
30+
'labels' => $labels,
31+
'menu_icon' => 'dashicons-format-quote',
32+
'show_in_menu' => true,
33+
'show_ui' => true,
34+
'show_in_nav_menus' => true,
35+
'public' => true,
36+
'publicly_queryable' => true,
37+
'has_archive' => true,
38+
'rewrite' => array( 'slug' => 'testimonial', 'with_front' => false ),
39+
'supports' => array( 'title', 'editor', 'thumbnail' ),
40+
);
41+
42+
register_post_type( 'testimonial', $args );
43+
44+
}
45+
add_action( 'init', 'ast_testimonial_post_type', 10, 1 );
46+
47+
/**
48+
* Edit columns
49+
*
50+
* @param array $columns
51+
* @return void
52+
*/
53+
function manage_testimonial_cols($columns) {
54+
55+
$inserted = array(
56+
'editor' => 'Testimonial',
57+
'thumbnail' => 'Testimonial Photo',
58+
);
59+
60+
return array_merge(
61+
array_slice($columns, 0, 2),
62+
$inserted,
63+
array_slice($columns, 2)
64+
);
65+
}
66+
add_filter( 'manage_testimonial_posts_columns', 'manage_testimonial_cols');
67+
68+
/**
69+
* Create Custom columns
70+
*
71+
* @param string $column_name
72+
* @param int $post_id
73+
* @return void
74+
*/
75+
function testimonial_field_col( $column_name, $post_id ){
76+
77+
if( $column_name == 'editor' ){
78+
echo "Rating: ".get_field( 'rating' );
79+
echo "<blockquote>\"".get_the_content()."\"</blockquote>";
80+
}
81+
82+
if( $column_name == 'thumbnail' ){
83+
echo get_the_post_thumbnail( $post_id, 'thumbnail' );
84+
}
85+
86+
}
87+
add_action( 'manage_testimonial_posts_custom_column', 'testimonial_field_col', 10, 2);

includes/security-actions.php

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
/**
3+
* Add actions related to Security.
4+
*
5+
*
6+
* @package astra-child-theme
7+
*/

includes/seo-actions.php

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
/**
3+
* Add actions related to SEO.
4+
*
5+
*
6+
* @package astra-child-theme
7+
*/

includes/theme-actions.php

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
/**
44
* Add actions related to Theme.
55
*
6-
* @link https://developer.wordpress.org/themes/basics/theme-functions/
76
*
87
* @package astra-child-theme
98
*/

includes/theme-functions.php

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
/**
3+
* Add Functions related to themes.
4+
*
5+
* @link https://developer.wordpress.org/themes/basics/theme-functions/
6+
*
7+
* @package astra-child-theme
8+
*/
9+
10+
require get_stylesheet_directory().'/includes/post-type/post-type.php';
11+
require get_stylesheet_directory(). '/includes/admin-settings.php';
12+
require get_stylesheet_directory(). '/includes/elementor-widgets.php';
13+
require get_stylesheet_directory(). '/includes/security-actions.php';
14+
require get_stylesheet_directory(). '/includes/seo-actions.php';
15+
require get_stylesheet_directory(). '/includes/theme-actions.php';
16+
require get_stylesheet_directory(). '/includes/user-actions.php';
17+
require get_stylesheet_directory(). '/includes/woo-actions.php';

includes/user-actions.php

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php

includes/widgets/wpg-widget.php

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
namespace Elementor;
4+
5+
class WPG_widget extends Widget_Base {
6+
7+
public function get_name() {
8+
return 'wpg-widget';
9+
}
10+
11+
public function get_title() {
12+
return 'WPG widget';
13+
}
14+
15+
public function get_icon() {
16+
return 'eicon-photo-library';
17+
}
18+
19+
public function get_categories() {
20+
return [ 'basic' ];
21+
}
22+
23+
public function get_style_depends() {
24+
//$styles = [ 'lightgallery-combined' ];
25+
26+
return $styles;
27+
}
28+
29+
public function get_script_depends() {
30+
//$scripts = [ 'lightgallery-medium-zoom' ];
31+
32+
return $scripts;
33+
}
34+
35+
protected function register_controls() {
36+
37+
$this->start_controls_section(
38+
'section_title',
39+
[
40+
'label' => __( 'WPG widget', 'elementor' ),
41+
]
42+
);
43+
44+
$this->add_control(
45+
'gallery_options',
46+
[
47+
'label' => esc_html__( 'WPG Control Settings', 'elementor' ),
48+
'type' => \Elementor\Controls_Manager::HEADING,
49+
'separator' => 'before',
50+
]
51+
);
52+
53+
$this->add_control(
54+
'wpg_active_background_color',
55+
[
56+
'label' => esc_html__( 'Background Color', 'plugin-name' ),
57+
'type' => \Elementor\Controls_Manager::COLOR,
58+
'selectors' => array(
59+
'.is-checked' => 'background-color: {{VALUE}};',
60+
),
61+
]
62+
);
63+
64+
$this->end_controls_section();
65+
}
66+
67+
protected function render() {
68+
$settings = $this->get_settings_for_display();
69+
$plugins = array();
70+
//$settings["wpg_active_background_color"]
71+
}
72+
73+
protected function content_template() {
74+
echo " Enter template code. ";
75+
76+
}
77+
78+
}

includes/woo-actions.php

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php

0 commit comments

Comments
 (0)