What is the purpose of running PHP-FPM in its own container instead in the same container as apache2/nginx?

I’m fairly new to Docker so excuse any obvious ignorance or misunderstandings. That said, I’ve been coding and configuring web applications for a long time now. I have recently been dabbling with some more sophisticated (Docker and “traditional”) web/application server setups and experimenting with performance enhancements and simplifying deployments.

My personal favorite configuration to use for most projects thus far is nginx as a (mostly) “static file” web server &&|| caching mechanism &&|| Load Balancer in a reverse proxy config with Apache v2.4+ as the “backend” which runs PHP (also Perl &&|| Python) in a “FastCGI” (PHP-FPM) configuration (with mod_php disabled) and mpm_events (instead of mpm_prefork). We can always add in something else also such as REDIS or memcached, where applicable (but I rarely see a significant performance gain when using Cloudflare caching).

I’ve been dabbling with a few different ways to keep my “favorite web server composition” flexible and “ephemeral” enough to accommodate any and all possible options for further performance gain or resource load management. What I keep seeing is that there seems to have been a shift towards using PHP-FPM in its own separate “stand-alone” Docker container sometimes around late 2019.

Why?

While I can appreciate keeping resources isolated and separate for an easier to debug/config/secure configuration(s), I don’t fully understand what the benefits are to having PHP-FPM in a separate Docker container that is implicitly REQUIRED by the application that the Docker containers are comprising.

If anything, having a separate PHP-FPM container seems like additional configuration, additional resource consumption and an even more complicated build/deploy consideration in a CI/CD pipeline.

I can even get onboard with “simple preference”, such as instead of using Apache2 and nginx on the same Ubuntu/Debian or RHEL/CentOS container, break off nginx into its own container(s) and simply config your hostname(s) &&|| IPs and ports appropriately.

But what is a practical use case and advantages for having PHP-FPM separated from Apache or nginx containers for any additional benefit beyond perhaps using more Dockerfile &&|| docker-compose.yaml and less ba.sh scripting to get the same job done? If any part of the application fails or falters, then functionality will suffer. The additional network &&|| docker-network communications and hostname resolutions seems like it would just be a performance penalty over combining certain aspects of the docker-composer-ed application together, rather than splitting them up simply for the sake of splitting them up.

Go to Source
Author: kanidrive

Website Migration and now Carousel isn’t working,

I recently had a website handed over to me, During the process the Original creator migrated the hosting and in the process broke multiple aspects of the website.

I’ve finally got it back to a working state just one more part that is making me scratch my head. The site has a carousel as part of a “showroom” page. From what I can see this is using a PHP template for the mentioned page.

It should be displaying the featured image with a carousel of the gallery along the bottom followed.
enter image description here Like This (It seems to work fine on the individual posts)

What I am getting is this:
enter image description here

I’m hoping someone here could hopefully guide me in the right direction of how to fix this.

this is the section of code I think is at fault.

<div style="" class="showrooms new-showrooms col col-lg-4"> 
<div id="carousel-<?php echo $postID;?>" class="carousel slide" data-ride="carousel" data-interval="false" data-ff-autoslide-time="0">
    <div class="carousel-inner">
        <?php $images = get_field('gallery_images'); 
            if( $images ): $i=0;
                foreach( $images as $image ): $i++;
        ?>
        <div class="item <?php if($i==1){ echo ' active '; }?>">
            <a class="fancybox" href="<?php echo $image['url'] ?>" rel="<?php echo $postID;?>-gal"><img src="<?php echo $image['sizes']['medium_large']; ?>" alt="<?php echo $image['alt']; ?>"></a>
        </div>                                            
        <?php endforeach; endif; ?>
    </div>
</div> 

<div class="thumbs clearfix">
    <div id="thumbcarousel-<?php echo $postID;?>" class="carousel slide" data-interval="false" data-ff-autoslide-time="0">
        <div class="carousel-inner">
            <?php $images = get_field('gallery_images'); 
                if( $images ): $i=0; $t = count($images);
                    foreach( $images as $image ): $i++;
            ?>                                  
            <?php if($i%4==1):?>
            <div class="item <?php if($i==1){ echo ' active '; } ?>">
            <?php endif; ?>       
            <div data-target="#carousel-<?php echo $postID;?>" data-slide-to="<?php echo $i-1;?>" class="thumb"><img src="<?php echo $image['sizes']['medium']; ?>"></div>
             <?php if($i%4==0 || $i==$t):?>
            </div><!-- /item -->
            <?php endif; ?>
         <?php endforeach; endif; ?>
        </div><!-- /carousel-inner -->
        
        <!-- /controls -->
        <a class="left carousel-control" href="#thumbcarousel-<?php echo $postID;?>" role="button" data-slide="prev">
            <span class="glyphicon glyphicon-chevron-left"></span>
        </a>
        <a class="right carousel-control" href="#thumbcarousel-<?php echo $postID;?>" role="button" data-slide="next">
            <span class="glyphicon glyphicon-chevron-right"></span>
        </a>
    </div> <!-- /thumbcarousel -->
</div><!-- /clearfix -->

Any Help would be much appreacited.

Thanks

Go to Source
Author: Kyle

How to update the 3rd level of a json

I have a json file that looks like this

{
    "PL001": {
        "player_name": "Player 1",
        "player_email": "playeremail@email.com",
        "hobbies": {
          "SP001": {
            "sport": "Soccer",
            "positions": {
              "FL1":{
                "position": "Goalie"
              }
            }
          }
        }
    },
    "PL002": {
      "player_name": "Player 2",
      "player_email": "playeremail2@email.com",
      "hobbies": {
        "SP002": {
          "sport": "Hockey",
          "positions": {
            "FL2":{
              "position": "goaltender"
            }
          }
        }
      }
    }
}

What I need to do is change my positions codes to my new ones so for example my FL2 will be PLFL2

I’ve managed to get to the positions code but I’m not sure as to how I should go about pushing the new code up without loosing data.

Here is my codes

$old_code = "FL2";
$new_code = "PLFL2";


$json = json_decode(file_get_contents(storage_path('/players.json')));

$result = [];
foreach ($json as $key => $value)
{
  foreach($value->hobbies as $hobbiesCode => $hobby)
  {
    foreach ($hobby->positions as $positionCode => $position)
    {
      $positionCode = $new_code;
    }
  }
}

and that is where I get stuck. I’m not sure how to now go and update my json file with the new codes

Go to Source
Author: Aurilie

Saving a user ID to MYSQL

Hi i have a MYSQL database which i need the logged in user to save information to. this is easy enough but i would like it to automatically save the users_id in the table also so that when i run a report on tables joined i can see who saved what.

Does anyone know how to do this? Below is what i have so far.. I can insert manually but would like the user_id to save from the logged in user.
Thank you in advance for any help.

function edit_rams(){
    include("inc/db.php");
    if(isset($_GET['edit_rams'])){
        $id=$_GET['edit_rams'];

        $get_op=$conn->prepare("SELECT * FROM rams WHERE id='$id'");
        $get_op->setFetchMode(PDO:: FETCH_ASSOC);
        $get_op->execute();
        $row=$get_op->fetch();

        echo"<h2>Edit Operative</h2><div class='cat'><div class='update'>
        <form class='edit_form' method='post' enctype='multipart/form-data'>
        <h2>Confimation</h2>
        <p>Are you sure you Want to complete this RAMS?</p>
        <p>By Agreeing to this you are declaring that you have read and understood everything contained within these RAMS</p>
       <center><button name='add_rams2'>Complete RAMS</button></center>
        </form><br /><br /><br /></div></div>";

if(isset($_POST['add_rams2'])){
            $ram_name=$_session['user(id)'];
            
            $add_rams2=$conn->prepare("INSERT into rams_1 (user_id, ram_id, signature)VALUES('$ram_name', '1', 'steve')");
            
if($add_rams2->execute()){
                echo"<script>alert('Operative Added Successfully')</script>";
                echo"<script>window.open('dashboard.php?test','_self')</script>";
                }else{
                    echo"<script>alert('Operative Not Added Successfully')</script>";
                    echo"<script>window.open('dashboard.php?test','_self')</script>";
                }
            }
    }
}`

Go to Source
Author: steven meadows

reversing php dencryption function using openssl_encrypt

hello all,

i’m solving a ctf challenge and i have this function that decrypts the cipher
i want to build a function that encrypts plain text using
vmUeu7D9bzE5JmNE as a key

example output:

//$EncString = encryptString("aaaaaaaaaaaaaaaaaaaaa", "vmUeu7D9bzE5JmNE");
 output:SElIT1dBUkVZT1VCUk8hIdk8ZHn/lvhO9Vammhqvg8N6OlV2KOX3uRiQ7gsn8ZXuvE4UUPOK9Q4ZhufvCiyXhAIdJxY+22Rt5AgkVy0CDcI=```

decryption function :

function decryptString($ciphertext, $password)
{
    $ciphertext = base64_decode($ciphertext);
    if (!hash_equals(hash_hmac('sha256', substr($ciphertext, 48) . substr($ciphertext, 0, 16) , hash('sha256', $password, true) , true) , substr($ciphertext, 16, 32))) 
        return null;
    return openssl_decrypt(substr($ciphertext, 48) , "AES-256-CBC", hash('sha256', $password, true) , OPENSSL_RAW_DATA, substr($ciphertext, 0, 16));
}

i want to reverse the decryption function , i tried but i couldn’t

Go to Source
Author: Mo Salah

js files occasionally failing to load

We have a newly configured php7 16cpu 32gb RAM Linux server.
Plenty of power for what we need.

We have a basic form on a page that requires a login.

However, sometimes when a user lands on the page, the js files fail to load which in turn prevents them from logging in.

This doesn’t happen every time, but often enough to where we cannot use the newly configured server.

KeepAlive is enabled, as seen by this curl command:

Content-Type: text/html; charset=UTF-8 Content-Length: 0 Connection: keep-alive

I have attached an image of what we’re seeing.

Could this have anything to do with server/Apache configuration, as we notice the js files always fail at the 10 second mark.

Btw,

enter image description here

Go to Source
Author: mcs

After creating Custom post type by user delete old one

I have created a form where users update their profile. When a profile is created or updated it creates a CPT called course. The url is the permalink + /course/ + the title of the course

/*  CREATING COURSE PAGES FROM USER PROFILES */

function create_course_page( $user_id = '' ) {
   $user = new WP_User($user_id);
   if ( ! $user->ID ) return '';

   // check if the user whose profile is updating has already a post
   global $wpdb;
   $course_post_exists = $wpdb->get_var( $wpdb->prepare(
   "SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type = 'course' and post_status = 'publish'", $user->course_name
   ) );

  if ( ! in_array('instructor', $user->roles) ) return '';

  $user_info = array_map( function( $a ){ return $a[0]; }, get_user_meta( $user->ID ) );
  $title = $user_info['course_name'];
  // of course create the content as you want
  $content = 'This is the page for: ';
  $content .= $user_info['description_course'];
  $post = array(
    'post_title' => $title,
    'post_name' => $user->course_name,
    'post_content' => $content,
    'post_status' => 'publish',
    'post_type' => 'course'
  );
  if ( $course_post_exists ) {
    $post['ID'] = $course_post_exists;
    wp_update_post( $post );
  } else {
    wp_insert_post( $post );
  }
}

add_action( 'personal_options_update', 'create_course_page' );
add_action( 'edit_user_profile_update', 'create_course_page' );

The problem that I’m facing is that when someone changes the title of the course it creates a new post with this url.

So I want to delete the old post when a title change is done on the course.

NOTE: When changing title of the course it changes the URL, that is why I think it takes like a new post.

I have customised this code a bit to do the job:

/* REMOVE OLD COURSES WHEN UPDATE */
add_action( 'admin_init', 'removing_older_posts' );
function removing_older_posts() {
    $args = array (
        'post_type'         => 'course',
        'author'            => get_current_user_id(),
        'orderby'           => 'date',
        );
    $query = new WP_Query( $args );

    if ( $query->have_posts() ) { //if the current user has posts under his/her name
        $i = 0; //create post counter
        while ( $query->have_posts() ) { //loop through each post
            $query->the_post(); //get the current post
            if ($i > 0) { //if you're not on the first post
                wp_delete_post( $query->post->ID, true ); //delete the post
            }
            $i++; //increment the post counter
        }
        wp_reset_postdata();
    }
}

But it isn’t working.

Appreciate any suggestion 🙂

Go to Source
Author: Zaesar

Issue with deploying a Laravel App to Cloud Foundry on IBM Cloud

I’m trying to deploy a basic Laravel application to Cloud Foundry on IBM Cloud. Below you can see the output after I ran ibmcloud cf push:

Invoking 'cf push'...

Pushing from manifest to org ***** / space dev as *****...
Using manifest file *****manifest.yml
Getting app info...
Updating app with these attributes...
  name:                testproject
  path:                *****
  buildpacks:
    https://github.com/cloudfoundry/php-buildpack.git#v4.4.13
  disk quota:          1G
  health check type:   port
  instances:           1
  memory:              64M
  stack:               cflinuxfs3
  env:
    APP_DEBUG
    CF_STAGING_TIMEOUT
    CF_STARTUP_TIMEOUT
  routes:
    testproject.us-south.cf.appdomain.cloud

Updating app testproject...
Mapping routes...
Comparing local files to remote cache...
Packaging files to upload...
Uploading files...
 8.35 MiB / 8.35 MiB [==========================================================] 100.00% 5s

Waiting for API to complete processing files...

Staging app and tracing logs...
   Cell 87626c63-eae1-42ff-a4fb-785ef79934bd creating container for instance cacf5821-7867-496a-8ace-b6ef71835d24
   Cell 87626c63-eae1-42ff-a4fb-785ef79934bd successfully created container for instance cacf5821-7867-496a-8ace-b6ef71835d24
   Downloading build artifacts cache...
   Downloading app package...
   Downloaded build artifacts cache (217B)
   Downloaded app package (12.1M)
   -------> Buildpack version 4.4.13
   Installing HTTPD
   HTTPD 2.4.43
   Downloaded [https://buildpacks.cloudfoundry.org/dependencies/httpd/httpd_2.4.43_linux_x64_cflinuxfs3_59c67ff8.tgz] to [/tmp]
   Installing PHP
   PHP 7.4.5
   Downloaded [https://buildpacks.cloudfoundry.org/dependencies/php/php7_7.4.5_linux_x64_cflinuxfs3_c0055c53.tgz] to [/tmp]
   The extension 'mcrypt' is not provided by this buildpack.
   Downloaded [https://buildpacks.cloudfoundry.org/dependencies/php/php7_7.4.5_linux_x64_cflinuxfs3_c0055c53.tgz] to [/tmp]
   Downloaded [https://buildpacks.cloudfoundry.org/dependencies/composer/composer_1.10.5_linux_noarch_any-stack_a1f79ebd.phar] to [/tmp]
     % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                    Dload  Upload   Total   Spent    Left  Speed
     0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
   100   482  100   482    0     0   2738      0 --:--:-- --:--:-- --:--:--  2754
   Loading composer repositories with package information
   Installing dependencies from lock file
   Package operations: 0 installs, 0 updates, 37 removals
     - Removing webmozart/assert (1.9.1)
     - Removing theseer/tokenizer (1.2.0)
     - Removing sebastian/version (2.0.1)
     - Removing sebastian/type (1.1.3)
     - Removing sebastian/resource-operations (2.0.1)
     - Removing sebastian/recursion-context (3.0.0)
     - Removing sebastian/object-reflector (1.1.1)
     - Removing sebastian/object-enumerator (3.0.3)
     - Removing sebastian/global-state (3.0.0)
     - Removing sebastian/exporter (3.1.2)
     - Removing sebastian/environment (4.2.3)
     - Removing sebastian/diff (3.0.2)
     - Removing sebastian/comparator (3.0.2)
     - Removing sebastian/code-unit-reverse-lookup (1.0.1)
     - Removing scrivo/highlight.php (v9.18.1.1)
     - Removing phpunit/phpunit (8.5.8)
     - Removing phpunit/php-token-stream (3.1.1)
     - Removing phpunit/php-timer (2.1.2)
     - Removing phpunit/php-text-template (1.2.1)
     - Removing phpunit/php-file-iterator (2.0.2)
     - Removing phpunit/php-code-coverage (7.0.10)
     - Removing phpspec/prophecy (1.11.1)
     - Removing phpdocumentor/type-resolver (1.3.0)
     - Removing phpdocumentor/reflection-docblock (5.2.0)
     - Removing phpdocumentor/reflection-common (2.2.0)
     - Removing phar-io/version (2.0.1)
     - Removing phar-io/manifest (1.0.3)
     - Removing nunomaduro/collision (v4.2.0)
     - Removing myclabs/deep-copy (1.10.1)
     - Removing mockery/mockery (1.4.1)
     - Removing hamcrest/hamcrest-php (v2.0.1)
     - Removing fzaninotto/faker (v1.9.1)
     - Removing filp/whoops (2.7.3)
     - Removing facade/ignition-contracts (1.0.1)
     - Removing facade/ignition (2.3.4)
     - Removing facade/flare-client-php (1.3.4)
     - Removing doctrine/instantiator (1.3.1)
   Generating optimized autoload files

     [RuntimeException]
     Could not scan for classes inside "database/seeds" which does not appear to be a file nor a folder

   install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...
   -----> Composer command failed
   Traceback (most recent call last):
     File "/tmp/buildpackdownloads/a299fb3027da6b25566e06badf712812/scripts/compile.py", line 59, in <module>
       .from_build_pack('lib/additional_commands')
     File "/tmp/buildpackdownloads/a299fb3027da6b25566e06badf712812/lib/build_pack_utils/builder.py", line 212, in extensions
       process_extension(path, ctx, 'compile', process, args=[self])
     File "/tmp/buildpackdownloads/a299fb3027da6b25566e06badf712812/lib/build_pack_utils/utils.py", line 69, in process_extension
       success(getattr(extn, to_call)(*args))
     File "/tmp/buildpackdownloads/a299fb3027da6b25566e06badf712812/extensions/composer/extension.py", line 444, in compile
       return composer.compile(install)
     File "/tmp/buildpackdownloads/a299fb3027da6b25566e06badf712812/lib/extension_helpers.py", line 154, in compile
       self._compile(install)
     File "/tmp/buildpackdownloads/a299fb3027da6b25566e06badf712812/extensions/composer/extension.py", line 196, in _compile
       self.run()
     File "/tmp/buildpackdownloads/a299fb3027da6b25566e06badf712812/extensions/composer/extension.py", line 343, in run
       *self._ctx['COMPOSER_INSTALL_OPTIONS'])
     File "/tmp/buildpackdownloads/a299fb3027da6b25566e06badf712812/extensions/composer/extension.py", line 390, in run
       shell=True)
     File "/tmp/buildpackdownloads/a299fb3027da6b25566e06badf712812/lib/build_pack_utils/runner.py", line 109, in stream_output
       raise CalledProcessError(retcode, cmd)
   build_pack_utils.runner.CalledProcessError: Command '<open file '<fdopen>', mode 'w' at 0x7f60ea7ac930>' returned non-zero exit status 1
   Failed to compile droplet: Failed to run finalize script: exit status 1
   Exit status 223
   Cell 87626c63-eae1-42ff-a4fb-785ef79934bd stopping instance cacf5821-7867-496a-8ace-b6ef71835d24
   Cell 87626c63-eae1-42ff-a4fb-785ef79934bd destroying container for instance cacf5821-7867-496a-8ace-b6ef71835d24
Error staging application: App staging failed in the buildpack compile phase
FAILED

Here is my composer.json file:

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.2.5",
        "fideloper/proxy": "^4.2",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^6.3",
        "laravel/framework": "^7.22.2",
        "laravel/tinker": "^2.0"
    },
    "require-dev": {
        "facade/ignition": "^2.0",
        "fzaninotto/faker": "^1.9.1",
        "mockery/mockery": "^1.3.1",
        "nunomaduro/collision": "^4.1",
        "phpunit/phpunit": "^8.5"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r "file_exists('.env') || copy('.env.example', '.env');""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

Here is my .pb-config/options.json file:

{
    "PHP_VERSION": "{PHP_70_LATEST}",
    "COMPOSER_VENDOR_DIR": "vendor",
    "WEBDIR": "public"
}

Here is my manifest.yml file:

---
 applications:
 - name: testproject
   memory: 64M
   buildpacks: [ https://github.com/cloudfoundry/php-buildpack.git#v4.4.13 ]
   random-route: true
   env:
     APP_DEBUG: false
     CF_STAGING_TIMEOUT: 15
     CF_STARTUP_TIMEOUT: 15

I want to point out that the directory database/seeds exists and it contains file DatabaseSeeder.php.

This is my first time with Cloud Foundry and IBM Cloud. Any help is greatly appreciated!

Go to Source
Author: RCRalph

How to enable HTML tags in category description without breaking the category page

I’m trying to include hyperlinks as part of the description on a category page.

Since WordPress strips the necessary HTML tags, I’ve added the following PHP code in a plugin, which stops the HTML tags from getting stripped:

add_action('init','disable_kses');

function disable_kses() {
    remove_filter('pre_term_description', 'wp_filter_kses');
    }

This lets me include HTML tags fine, but when I include a hyperlink in the description, it breaks the page in a weird way, with material from the description being reproduced above the header. This includes all the text from the first hyperlink until the end of the description, but the first link itself isn’t reproduced (only the text for it is). In addition, at the very end of the material, the following is appended to the text:

“>

Other than that, in the place where the description should appear (under the title), everything renders properly, including the hyperlinks.

The HTML that I use to include the hyperlinks is standard:

<a href="http://example.org/">example</a>

My question is what should I be doing differently in order to be able to include hyperlinks as part of the category page description?

Go to Source
Author: Thredolsen

Remove add_action from plugin

I use this plugin. Is for auto expire user on specific date.

I want to add this action add_action(‘edit_user_profile’, array($this, ‘extra_user_profile_fields’)) when is_admin only because i have a conflict with an other plugin. I have try this to source code:

if (is_admin) {
add_action('edit_user_profile', array($this, 'extra_user_profile_fields'))
}

and all work well! But i want to add a function to child theme.

class Expire_User_Admin
{

    var $settings = null;

    public function __construct()
    {
        $this->settings = new Expire_User_Settings();

        // Admin Actions
        add_action('admin_init', array($this, 'expire_user_now'));

        // Profile Fields

        add_action('show_user_profile', array($this, 'extra_user_profile_fields'));
        add_action('edit_user_profile', array($this, 'extra_user_profile_fields'));
        add_action('user_new_form', array($this, 'user_new_form')); 

...
}

So i have try this with no luck. Any thoughts?

add_action('init', 'remove_plugin_action', 9999);
function remove_plugin_action()
{
    $plugin_class = new Expire_User_Admin();    
    remove_action('edit_user_profile', array($plugin_class, 'extra_user_profile_fields'));
    if (is_admin()) {
     add_action('edit_user_profile', array($plugin_class, 'extra_user_profile_fields'));
    }
}

Go to Source
Author: xiamtoula

Timer refresh page in a function

In my function I have a page refresh at the end to actually update the table, however the refresh is faster than the database.

Anyone have an idea how I can change this?

echo '<script>                                                                          ';
echo 'function updateId(id) {                                                             ';
echo 'var xmlhttp = new XMLHttpRequest();                                               ';
echo '    xmlhttp.onreadystatechange = function() {                                     ';
echo '        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)                     ';
echo '        {                                                                         ';
//echo '            alert(xmlhttp.responseText);                                          ';
echo '        }                                                                         ';
echo '    };                                                                            ';
echo '    xmlhttp.open("GET", "update.php?id=" +id, true);                              ';
echo '    xmlhttp.send();                                                               ';
echo 'location.reload(true);                                                                ';

echo '}                                                                                 ';
echo '</script>                                                                         ';
?>

Go to Source
Author: Tjerk Peters

Child theme overirde template-tags in a theme built on underscores in inc/template-tags

I’ve read this post and I don’t think this question is a duplicate because I have a specific question that has not been answered.

My parent theme is using the following to require a template tag php file

require get_template_directory() . '/inc/template-tags.php';

Is it possible to overide this in my child theme, If I place the same code in my functions.php and place the folder and file the same in my child theme folder I get a error saying

 Fatal error: Cannot redeclare progression_studios_category_transient_flusher() (previously declared in /home/anders/Local Sites/site/app/public/wp-content/themes/vayvo-progression-child/inc/template-tags.php:401) in /home/anders/Local Sites/site/app/public/wp-content/themes/vayvo-progression/inc/template-tags.php on line 401

Is it possible to work around this.

Thanks ahead of time.

Go to Source
Author: Anders Kitson

Ubuntu 18.04LTS apache2 parse php in html

on ubuntu 16.04LTS the following lines added to apache2.conf via IncludeOptional prevent indexing and allow parsing of php in html files

    Options FollowSymLinks
    AllowOverride None
</Directory>

<Directory /var/www/>
    Options -Indexes +FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

AddType application/x-httpd-php .php .htm .html

The same code added on a 18.04LTS server prevent indexing but wont parse php in html.
It’s a long time since I set up the 16.06 Is there a change in 18.04 or am I forgetting something.

Go to Source
Author: FRANK POLAN

Where to find documentation for CPT block template? (PHP)

I have been searching for a day and still carn’t seem to find the right documentation for what arguments I can pass to core components when attempting to configure a CPT block template in php. This is what I have but I want to take this further by nesting buttons and custom html etc. but carnt find the docs I need.

'template' => array(
    array( 'core/columns', array(), array(
        array( 'core/column', array("width" => "60"), array(
            array( 'core/image', array() ),
        ) ),
        array( 'core/column', array("width" => "40"), array(
            array( 'core/image', array() ),
            array( 'core/heading', array(
                'placeholder' => 'Add a inner paragraph'
            ) ),
        ) ),
    )
)       

Found everything needed to create bespoke blocks in JSX but blegh, Not got the time to learn the wizardry ways of JSX just yet and I dont really want new blocks just want the existing one bound as a template to a custom post type.

A good way to example my question, how did this person find the answer on how set the width of this template columns.

How to set column widths in a CPT block template?

How did the person find this answer ? did they have to dive in to the JS scripts of the component and work it out or is there some documentation on this or am I missing something all together.

Any help would be greatly appreciated.

Go to Source
Author: Johnny