$styles ) { $result .= $sel . " {\n"; foreach ( $styles as $prop => $val ) { $result .= " {$prop}: {$val};\n"; } $result .= "}\n"; } // Custom CSS. if ( isset( $options['custom_css'] ) && $options['custom_css'] ) { // decode. $custom_css = visual_portfolio_decode( $options['custom_css'] ); // replace 'selector' to actual css selector. $custom_css = str_replace( 'selector', $selector, $custom_css ); // a little security fix. $custom_css = str_replace( '', $custom_css ); $custom_css = str_replace( '\"', '"', $custom_css ); $custom_css = str_replace( "\'", "'", $custom_css ); } $result .= $custom_css; } return $result; } /** * Prepare styles from params * Params example: array( 'element' => '$ .inner-selector', 'property' => 'height', 'mask' => '$px', ) * * @param string $selector CSS selector. * @param mixed $value Property value. * @param array $params Output params. * * @return array|bool */ public static function prepare_styles_from_params( $selector, $value, $params ) { if ( ! $selector || ! isset( $value ) || '' === $value || null === $value || ! isset( $params['property'] ) ) { return false; } // Value mask. if ( isset( $params['mask'] ) ) { $value = str_replace( '$', $value, $params['mask'] ); } // Custom selector mask. if ( isset( $params['element'] ) && strpos( $params['element'], '$' ) !== false ) { $selector = str_replace( '$', $selector, $params['element'] ); } else { $selector = $selector . ( isset( $params['element'] ) ? ( ' ' . $params['element'] ) : '' ); } $property = $params['property']; return array( $selector => array( $property => $value, ), ); } }