Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/Admin/AdminOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function index(): void
'gallery',
'search-form',
'script',
'style'
'style',
]);
remove_theme_support('block-templates');
remove_theme_support('core-block-patterns');
Expand Down Expand Up @@ -67,7 +67,7 @@ public function registerScripts(): void

wp_localize_script('app', 'data', [
'ajax_url' => admin_url('admin-ajax.php'),
'nonce' => wp_create_nonce('ajax-nonce'),
'nonce' => wp_create_nonce('ajax-nonce'),
]);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Controllers/Api/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ApiController
public function index(): array
{
return [
'title' => 'title'
'title' => 'title',
];
}
}
4 changes: 2 additions & 2 deletions app/Controllers/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public function list(): array
}

$this->data['posts'] = Timber::get_posts([
'post_type' => 'post',
'post_type' => 'post',
'posts_per_page' => 10,
'paged' => $paged,
'paged' => $paged,
]);

$this->data['categories'] = Timber::get_terms('category');
Expand Down
2 changes: 1 addition & 1 deletion app/CustomFields/Blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
* post/page blocks
*/
add_action('carbon_fields_register_fields', function () {
include __DIR__ . '/Blocks/example.php';
include __DIR__.'/Blocks/example.php';
});
5 changes: 2 additions & 3 deletions app/CustomFields/Blocks/example.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

wp_register_style(
'crb-my-shiny-gutenberg-block-stylesheet',
get_stylesheet_directory_uri() . '../app/CustomFields/Blocks/example.css'
get_stylesheet_directory_uri().'../app/CustomFields/Blocks/example.css'
);


Block::make(__('My Gutenberg Block'))
->add_fields([
Field::make('text', 'heading', __('Block Heading')),
Expand All @@ -18,5 +17,5 @@
->set_description(__('Description for the block'))
->set_editor_style('crb-my-shiny-gutenberg-block-stylesheet')
->set_render_callback(function ($fields, $attributes, $inner_blocks) {
include(__DIR__ . '/example.view.php');
include __DIR__.'/example.view.php';
});
4 changes: 2 additions & 2 deletions app/CustomFields/PostFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* post/page fields
*/
add_action('carbon_fields_register_fields', function () {
include __DIR__ . '/Fields/home.php';
include __DIR__ . '/Fields/about.php';
include __DIR__.'/Fields/home.php';
include __DIR__.'/Fields/about.php';
// Container::make( 'comment_meta', 'Comment fields' )
// ->add_fields( array(
// Field::make( 'text', 'comment_rating', 'Rating' ),
Expand Down
8 changes: 4 additions & 4 deletions app/Handlers/AjaxHandlers/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
}

$isMailSent = send_email('test', [
'subject' => 'test form',
'subject' => 'test form',
'site_name' => get_bloginfo('name'),
'name' => $name,
'mail' => $mail,
'name' => $name,
'mail' => $mail,
]);

if ($isMailSent) {
wp_send_json([
'type' => 'success',
'type' => 'success',
'message' => 'Your request has been successfully sent, thank you!',
]);
} else {
Expand Down
8 changes: 4 additions & 4 deletions app/Handlers/AjaxHandlers/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
}

$credentials = [
'user_login' => $email,
'user_login' => $email,
'user_password' => $password,
'remember' => true,
'remember' => true,
];

$user = wp_signon($credentials, false);

if (is_wp_error($user)) {
wp_send_json([
'type' => 'error',
'type' => 'error',
'message' => json_decode($user->get_error_message()),
]);
}

wp_send_json([
'type' => 'success',
'type' => 'success',
'message' => 'Your successfully enter',
]);
36 changes: 25 additions & 11 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
if (!function_exists('send_email')) {
/**
* Send a custom email.
*
* @param string $templateFilename
* @param array $templateData
* @param array $templateData
*
* @return bool|null
*/
function send_email(string $templateFilename, array $templateData): ?bool
Expand All @@ -19,19 +21,23 @@ function send_email(string $templateFilename, array $templateData): ?bool

/**
* Compile an email template.
*
* @param string $filename
* @param array $data
* @param array $data
*
* @return string
*/
function compile_email_template(string $filename, array $data): string
{
return Timber::compile('/resources/views/emails/' . $filename . '.twig', $data);
return Timber::compile('/resources/views/emails/'.$filename.'.twig', $data);
}

/**
* Dispatch an email.
*
* @param string $subject
* @param string $body
*
* @return bool
*/
function dispatch_email(string $subject, string $body): bool
Expand All @@ -41,7 +47,7 @@ function dispatch_email(string $subject, string $body): bool
$toEmail = $adminEmail;

$headers[] = 'Content-type: text/html; charset=utf-8';
$headers[] = 'From: ' . $fromEmail;
$headers[] = 'From: '.$fromEmail;

return wp_mail($toEmail, $subject, $body, $headers);
}
Expand All @@ -50,24 +56,26 @@ function dispatch_email(string $subject, string $body): bool
if (!function_exists('add_ajax_action')) {
/**
* Registers an AJAX action with WordPress.
*
* @param string $name The name of the AJAX action.
*/
function add_ajax_action(string $name): void
{
$action_path = APP_PATH . '/Handlers/AjaxHandlers/' . $name . '.php';
$action_path = APP_PATH.'/Handlers/AjaxHandlers/'.$name.'.php';
add_ajax_action_impl($name, 'wp_ajax', $action_path);
add_ajax_action_impl($name, 'wp_ajax_nopriv', $action_path);
}

/**
* Helper function to implement AJAX action registration.
* @param string $name The name of the AJAX action.
* @param string $hook The WordPress hook to associate with the action.
*
* @param string $name The name of the AJAX action.
* @param string $hook The WordPress hook to associate with the action.
* @param string $action_path Path to the PHP file that handles the action.
*/
function add_ajax_action_impl(string $name, string $hook, string $action_path): void
{
add_action($hook . "_$name", function () use ($action_path) {
add_action($hook."_$name", function () use ($action_path) {
require $action_path;
});
}
Expand All @@ -76,19 +84,21 @@ function add_ajax_action_impl(string $name, string $hook, string $action_path):
if (!function_exists('dd')) {
/**
* Debug function to dump and die. Outputs the given variable and stops execution.
*
* @param mixed $result The variable to be dumped.
*/
function dd(mixed $result): void
{
echo '<pre>';
print_r($result);
die();
exit;
}
}

if (!function_exists('crb_get_i18n_suffix')) {
/**
* Get the suffix for internationalization, typically a language code.
*
* @return string The suffix for the current language, or an empty string if not set.
*/
function crb_get_i18n_suffix(): string
Expand All @@ -97,19 +107,23 @@ function crb_get_i18n_suffix(): string
if (!defined('ICL_LANGUAGE_CODE')) {
return $suffix;
}
return '_' . ICL_LANGUAGE_CODE;

return '_'.ICL_LANGUAGE_CODE;
}
}

if (!function_exists('crb_get_i18n_theme_option')) {
/**
* Retrieves a theme option value with internationalization support.
*
* @param string $option_name The name of the theme option.
*
* @return mixed The value of the theme option for the current language.
*/
function crb_get_i18n_theme_option(string $option_name): mixed
{
$suffix = crb_get_i18n_suffix();
return carbon_get_theme_option($option_name . $suffix);

return carbon_get_theme_option($option_name.$suffix);
}
}
2 changes: 1 addition & 1 deletion bootstrap/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use App\Admin\HiddenData;
use Core\AppConfig;

$configPath = __DIR__ . '/../config/admin.php';
$configPath = __DIR__.'/../config/admin.php';
$config = include $configPath;

new AppConfig($config);
Expand Down
8 changes: 4 additions & 4 deletions config/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* basic admin theme options.
*/
return [
'show_posts' => true,
'show_pages' => true,
'show_posts' => true,
'show_pages' => true,
'enable_comments' => true,
'show_tools' => true,
'show_admin_bar' => true,
'show_tools' => true,
'show_admin_bar' => true,
];
Loading
Loading