Theme function exists checks #129

Closed
justintadlock opened this Issue Jan 10, 2017 · 2 comments

Projects

None yet

3 participants

@justintadlock

This is a bit trivial and not a necessary change. It'll just help cut back on unnecessary code.

I was wondering why you're checking if the shapely_get_layout_class() function exists in multiple templates:

<?php $layout_class = ( function_exists( 'shapely_get_layout_class' ) ) ? shapely_get_layout_class() : ''; ?>

The theme defines the function, so there really shouldn't be a need to check if it exists. I'd just write the code as:

<?php $layout_class = shapely_get_layout_class(); ?>

This is in the following files:

  • archive.php
  • index.php
  • page.php
  • search.php
  • single.php
  • page-templates/full-width.php
  • page-templates/sidebar-left.php
  • page-templates/sidebar-right.php

Same thing in comments.php:

$comments_args = ( function_exists( 'shapely_custom_comment_form' ) ) ? shapely_custom_comment_form() : '';

No need to check if a function exists if your theme is creating the function.

@c0sm1n87
Collaborator

@justintadlock I think all the functions from this theme are using function_exists.. to be completely honest - I have no idea why. I guess it had something to do with the companion plugin ( maybe they were moved from there )

@cristianraiber cristianraiber modified the milestone: Shapely 1.1.0 Jan 11, 2017
@cristianraiber
Collaborator

Fixed in: 188b1d6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment