Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
cardania-devops authored Jan 13, 2024
0 parents commit 0a64534
Show file tree
Hide file tree
Showing 23 changed files with 713 additions and 0 deletions.
1 change: 1 addition & 0 deletions admin/admin-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// JavaScript for admin area
1 change: 1 addition & 0 deletions admin/admin-style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Admin CSS styles */
7 changes: 7 additions & 0 deletions admin/class-ai-autoblogger-admin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
class AIAutoblogger_Admin {

// Admin-related methods
// ...

}
28 changes: 28 additions & 0 deletions admin/settings-page.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
// Check user capabilities
if (!current_user_can('manage_options')) {
return;
}

// Fetch saved options
$options = get_option('ai_autoblogger_options');
?>
<div class="wrap">
<h1><?= esc_html(get_admin_page_title()); ?></h1>

<!-- Settings form -->
<form action="options.php" method="post">
<?php
settings_fields('ai-autoblogger');
do_settings_sections('ai-autoblogger');
submit_button();
?>
</form>

<!-- Manual post generation form -->
<form action="<?php echo esc_url(admin_url('admin.php?page=ai-autoblogger')); ?>" method="post">
<?php wp_nonce_field('ai_autoblogger_generate_post'); ?>
<input type="hidden" name="action" value="generate_post">
<?php submit_button('Generate Post Now'); ?>
</form>
</div>
43 changes: 43 additions & 0 deletions admin/views/settings-page
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
// Check user capabilities
if (!current_user_can('manage_options')) {
return;
}

// Fetch saved options
$options = get_option('ai_autoblogger_options');
?>
<div class="wrap">
<h1><?= esc_html(get_admin_page_title()); ?></h1>
<form action="options.php" method="post">
<?php
settings_fields('ai-autoblogger');
do_settings_sections('ai-autoblogger');

// Add your fields here
?>
<h2>General Settings</h2>
<table class="form-table">
<tr>
<th scope="row"><label for="ai_autoblogger_api_key">OpenAI API Key</label></th>
<td>
<input type="text" id="ai_autoblogger_api_key" name="ai_autoblogger_options[api_key]" value="<?php echo esc_attr($options['api_key'] ?? ''); ?>" class="regular-text">
</td>
</tr>
<tr>
<th scope="row"><label for="ai_autoblogger_post_frequency">Post Frequency</label></th>
<td>
<select id="ai_autoblogger_post_frequency" name="ai_autoblogger_options[post_frequency]">
<option value="30min" <?php selected($options['post_frequency'], '30min'); ?>>Every 30 minutes</option>
<option value="1hour" <?php selected($options['post_frequency'], '1hour'); ?>>Every hour</option>
<option value="3hours" <?php selected($options['post_frequency'], '3hours'); ?>>Every 3 hours</option>
<!-- Add more options as needed -->
</select>
</td>
</tr>
<!-- Add more settings fields as needed -->
</table>

<?php submit_button('Save Settings'); ?>
</form>
</div>
19 changes: 19 additions & 0 deletions ai-autoblogger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* Plugin Name: AI Autoblogger
* Description: Automatically generates blog posts using OpenAI.
* Version: 1.0
* Author: Your Name
* Text Domain: ai-autoblogger
*/

// If this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}

// Include the main AI Autoblogger class from the 'includes' folder.
require_once plugin_dir_path( __FILE__ ) . 'includes/class-ai-autoblogger.php';

// Begins execution of the plugin by instantiating the main class.
$plugin = new AIAutoblogger();
4 changes: 4 additions & 0 deletions assets/css/frontend-style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Styles for frontend display of AI-generated posts */
.ai-post {
/* Style for AI post */
}
4 changes: 4 additions & 0 deletions assets/js/frontend-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// JavaScript for frontend interactions
document.addEventListener('DOMContentLoaded', function() {
// Your code here
});
18 changes: 18 additions & 0 deletions docs/developer-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Developer Guide for AI Autoblogger

## Overview
This document is for developers looking to understand or contribute to the AI Autoblogger plugin.

## Plugin Architecture
- Overview of the plugin structure
- Description of key classes and functions

## Extending the Plugin
- How to add new features
- Guidelines for contributing

## API Reference
- Detailed API documentation

## Contact
- How to get in touch for development-related queries
47 changes: 47 additions & 0 deletions docs/file-structure
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# AI Autoblogger Plugin File Structure

This document outlines the file structure for the AI Autoblogger WordPress plugin.

## Root Directory

- `ai-autoblogger.php`: The main plugin file which initializes the plugin.

## Includes

- `class-ai-autoblogger.php`: Main class file for the plugin's functionality.
- `class-openai-api.php`: Handles integration with the OpenAI API.
- ...

## Admin

- `class-ai-autoblogger-admin.php`: Manages admin-specific functionality.
- `views/`: Contains admin view templates.

## Assets

- `css/`: CSS files for styling.
- `js/`: JavaScript files for interactive functionality.

## Templates

- `custom-post-type-template.php`: Template for custom post types.

## Languages

- Localization files for the plugin.

## Docs

- Documentation files including user guides and developer information.

## Tests

- `tests.php`: Unit tests for the plugin.

## Vendor

- External libraries used by the plugin.

## Readme

- `readme.txt`: Basic plugin information and instructions.
18 changes: 18 additions & 0 deletions docs/user-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# User Guide for AI Autoblogger

## Introduction
This guide provides instructions on how to use the AI Autoblogger plugin.

## Getting Started
- Installation steps
- Setting up

## Creating Posts
- How to generate posts
- Configuring post settings

## FAQs
- Frequently asked questions

## Support
- Contact info for support
19 changes: 19 additions & 0 deletions includes/ajax-handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
// Handle AJAX requests here
add_action('wp_ajax_generate_post', 'handle_generate_post_ajax');

function handle_generate_post_ajax() {
check_ajax_referer('ai_autoblogger_generate_post');

$openai_api = new OpenAI_API(); // Ensure this is correctly instantiated
$post_generator = new Post_Generator($openai_api);
$result = $post_generator->generate_and_publish_post();

if ($result === false) {
wp_send_json_error('Failed to generate post');
} else {
wp_send_json_success('Post generated successfully');
}

wp_die(); // Terminate AJAX request
}
37 changes: 37 additions & 0 deletions includes/class-ai-autoblogger-admin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* The admin-specific functionality of the plugin.
*/

class AIAutoblogger_Admin {

/**
* Register the settings page for the plugin.
*/
public function __construct() {
add_action('admin_menu', array($this, 'add_settings_page'));
}

/**
* Add settings page to the WordPress admin menu.
*/
public function add_settings_page() {
add_options_page(
'AI Autoblogger Settings',
'AI Autoblogger',
'manage_options',
'ai-autoblogger',
array($this, 'display_settings_page')
);
}

/**
* Display the settings page content.
*/
public function display_settings_page() {
// Include the settings page view
include_once plugin_dir_path(__FILE__) . 'views/settings-page.php';
}

// Additional methods for handling settings...
}
Loading

0 comments on commit 0a64534

Please sign in to comment.