Skip to content

Forum in maintenance, we will back soon 🙂

The UI and The PHP ...
 
Notifications
Clear all

The UI and The PHP Code

34 Posts
11 Users
20 Reactions
704 Views
(@google-businessgmail)
Posts: 25
Eminent Member
Topic starter
 

I watched your recent Video About Building A Blog Title Generator As Example But I have My Own Gemini API Key and I did as You did In The Video Both Code Which UI and PHP Code Is Not Working I installed The Wp-code Plugin Which You recomended in The Video But The UI image and PHP functions Are.......Dead See the Below image I know my English I hope You Understand it

Screenshot 2024 03 22 064448

 or You Can See it in this link https://muhtadun.com/blog-title-generator/

 
Posted : 03/22/2024 3:48 am
young bd and badr reacted
Hasan Aboul Hasan
(@admin)
Posts: 1244
Member Admin
 

Did you change the website URL in the JS file?

 
Posted : 03/22/2024 12:32 pm
young bd and badr reacted
 badr
(@badrsabra)
Posts: 29
Eminent Member
 

@admin thank you hasan ihave  same problem also can you explain were can i found website url in the js file

 
Posted : 03/22/2024 9:24 pm
(@google-businessgmail)
Posts: 25
Eminent Member
Topic starter
 

@admin Tnx! I fixed but the main game is in the PHP code wich i am struggling with it Please make a blog about your recent video most person stuck in php code function pls!

 
Posted : 03/22/2024 9:37 pm
badr reacted
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

@google-businessgmail and @badrsabra, see lines 92, 113, 119, 141 and 146 of the file posted at https://learnwithhasan.com/custom-code/ai-tool-on-wordpress-ui/ where you need to change the URL

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 03/22/2024 9:58 pm
badr reacted
 badr
(@badrsabra)
Posts: 29
Eminent Member
 

@ssadvisor thank you very much for your kindness you here every time i ask about anything

 
Posted : 03/22/2024 10:09 pm
 badr
(@badrsabra)
Posts: 29
Eminent Member
 

@ssadvisor fetch('http://wordpress-test.local/wp-admin/admin-ajax.php', {

with this code what should i do i write it like that

fetch('http://ai.superseotools.net/wp-admin/admin-ajax.php', { 

but i get erorr

 
Posted : 03/23/2024 7:21 pm
 badr
(@badrsabra)
Posts: 29
Eminent Member
 
    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: #f4f4f4;
            color: #333;
            line-height: 1.6;
            padding: 20px;
        }

        .container {
            max-width: 600px;
            margin: auto;
            background: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            text-align: center;
        }

        .input-group {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 20px;
        }

        input[type="text"] {
            flex-grow: 1;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            margin-right: 10px;
        }

        button {
            background: #007bff;
            color: #fff;
            border: 0;
            padding: 10px 20px;
            border-radius: 4px;
            cursor: pointer;
        }

        button:hover {
            background: #0056b3;
        }

        .result-item {
            background-color: #f2f2f2;
            margin-bottom: 10px;
            padding: 10px;
            border-radius: 5px;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .copy-button {
            background: #007bff;
            color: #fff;
            border: none;
            padding: 5px 10px;
            border-radius: 4px;
            cursor: pointer;
        }

        .copy-button:hover {
            background: #0056b3;
        }

        .image-container {
            margin-bottom: 20px;
        }

        @media screen and (max-width: 768px) {
            body, .container, .input-group {
                padding: 10px;
            }
        }
    .hidden {
            display: none;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="input-group">
            <input type="text" id="inputInput" placeholder="Enter a input (e.g., Facebook Ads)">
            <button id="generateButton">Generate Titles</button>
        </div>
        <div id="imageContainer" class="image-container">
            <img src="https://ai.superseotools.net/" alt="Getting Started" style="max-width: 100%;">
        </div>

        <ul id="titleList"></ul>

        
    </div>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const generateButton = document.getElementById('generateButton');
            const titleList = document.getElementById('titleList');
            const inputInput = document.getElementById('inputInput');
            const imageContainer = document.getElementById('imageContainer');

            generateButton.addEventListener('click', function() {
                const input = inputInput.value;
                if (!input) {
                    alert('Please enter a input.');
                    return;
                }

                imageContainer.innerHTML = '<img src="https://ai.superseotools.net" alt="Loading" style="max-width: 20%;">'; // Replace 'https://ai.superseotools.net' with your loading GIF

        // Clear existing titles and show the loading GIF
                titleList.innerHTML = '';
                imageContainer.classList.remove('hidden'); 

                fetch('https://ai.superseotools.net/wp-admin/admin-ajax.php', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/x-www-form-urlencoded'
                    },
                    body: 'action=custom_tool_run&input=' + encodeURIComponent(input)
                })
                .then(response => response.json())
                .then(jsonResponse => {
                    titleList.innerHTML = '';
                    if (jsonResponse.success) {
                        const titles = jsonResponse.data[0].titles;

                        titles.forEach(title => {
                            let listItem = document.createElement('li');
                            listItem.className = 'result-item';
                            listItem.innerHTML = `<span>${title}</span> <button class="copy-button" onclick="copyToClipboard('${title}')">Copy</button>`;
                            titleList.appendChild(listItem);
                        });
                        imageContainer.classList.add('hidden'); // Hide the image container
                    } else {
                        console.error('Failed to fetch titles');
            imageContainer.innerHTML = '<img src="https://ai.superseotools.net" alt="Error" style="max-width: 100%;">' +
                                               '<p>Oops! Something went wrong. Please try again.</p>';                   }
                })
                .catch(error => {
                    console.error('Error:', error);
                    imageContainer.innerHTML = '<img src="https://ai.superseotools.net" alt="Error" style="max-width: 100%;">' +
                                               '<p>Oops! Something went wrong. Please try again.</p>'; 

                });
            });

            window.copyToClipboard = function(text) {
            var textArea = document.createElement("textarea");
            textArea.value = text;
            textArea.style.top = "0";
            textArea.style.left = "0";
            textArea.style.position = "fixed";
            document.body.appendChild(textArea);
            textArea.focus();
            textArea.select();

            try {
                var successful = document.execCommand('copy');
                var msg = successful ? 'successful' : 'unsuccessful';
                alert('Copying text was ' + msg);
            } catch (err) {
                alert('Unable to copy text');
                console.error('Unable to copy', err);
            }

            document.body.removeChild(textArea);
        };

        });
    </script>
 
Posted : 03/23/2024 8:23 pm
 badr
(@badrsabra)
Posts: 29
Eminent Member
 

@google-youngbd  its not working

 
Posted : 03/23/2024 9:21 pm
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

@badrsabra what do you see when you use the inspect function of the browser?

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 03/24/2024 1:31 am
badr reacted
(@google-technicalsir)
Posts: 9
Active Member
 

Same problem but No solution. Please help me with detailed solution

 
Posted : 03/24/2024 6:31 am
badr reacted
(@google-technicalsir)
Posts: 9
Active Member
 

@ssadvisor I have updated the link to: http://quicktools.rf.gd.local/wp-admin/admin-ajax.php

 
Posted : 03/24/2024 6:57 am
badr reacted
(@husein)
Posts: 520
Member Moderator
 

@google-technicalsir @badrsabra I just did it again from scratch, and for it to work I only had to do 2 things:

  • Generate my own Gemini Key and replace it
  • Replace the URL with my own URL (I used a local host so I just changed it to the name of my local wp)
 
Posted : 03/24/2024 10:10 am
badr reacted
(@husein)
Posts: 520
Member Moderator
 

@google-technicalsir @badrsabra I tested both your URLs on reqbin and it gave me and error: "Could not resolve the host name. Error code: 1006"

So its probably something from your side, the function is working normally.

 
Posted : 03/24/2024 10:14 am
badr and SSAdvisor reacted
 badr
(@badrsabra)
Posts: 29
Eminent Member
 

@husein if my domin is superseotools.net what should i writ here 

fetch('http://     /wp-admin/admin-ajax.php', {
method: 'POST',
headers: {

 
Posted : 03/24/2024 10:40 pm
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

@badrsabra what do you think it should be? I'm asking you because I think it should be obvious. You also need to modify the http to https if that is what is expected.

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 03/25/2024 1:27 am
 badr
(@badrsabra)
Posts: 29
Eminent Member
 

I think it should be

fetch('https://superseotools.net/wp-admin/admin-ajax.php', {

method: 'POST',

headers: {

Or

fetch('https://www.superseotools.net/wp-admin/admin-ajax.php', {

method: 'POST',
headers: {

Or

fetch('https://superseotools.net/Public_html/wp-admin/admin-ajax.php', {
method: 'POST',
headers: {

 

I don't know what is the right way i try all of that but get errors 404 when  use the inspect function of the browser?

 
Posted : 03/25/2024 10:48 am
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

@badrsabra your server seems to be having issues at the moment but the answer will be related to how you access the 'wp-admin' login. This is simple enough for you to just try using the URL entry of your web browser.

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 03/25/2024 12:49 pm
 badr
(@badrsabra)
Posts: 29
Eminent Member
 

@ssadvisor Error: TypeError: Cannot read properties of undefined (reading '0')

 
Posted : 03/31/2024 4:00 pm
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

So your javascript is trying to read data that isn't available.

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 03/31/2024 6:31 pm
Page 1 / 2
Share: